How to generate customize auto generated ids in grails?

You can customize random ids generated by GORM.

For this Hibernate has provided id-generator. You can customize the id generator and the column it maps to as follows:

class Person {

static mapping = {
table ‘people’
version false
id generator: ‘hilo’,
params: [table: 'hi_value',
column: 'next_value',
max_lo: 100]
}
}

Here , ‘hilo’ is  Hibernate’s built in generator that uses a separate table to generate ids.


ProsperaSoft offers Grails development solutions. You can email at info@prosperasoft.com to get in touch with ProsperaSoft Grails experts and consultants.

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>