According to this answer , it is not possible to use sleep mode generators (those used for identifiers). If you really need to use Hibernate generators, the workaround is described in the answer too.
In your case, you can use an interceptor to generate your ponum property when inserting a new object:
class Yours { int ponum def beforeInsert() { def lastPonum = Book.list([sort: 'ponum', order:'desc', max: 1]) if(lastPonum) ponum = (lastPonum.pop().ponum as int) + 1 as String else ponum = '0' } }
source share