@TableGenerator realisation does not respect initialValue
Description
Activity
Steve Ebersole September 19, 2010 at 5:42 PM
We have a new set of generators that do this correctly. If you want to use them, specify 'hibernate.id.new_generator_mappings' as true in your config (see HHH-4690).
Tim Vollmer September 19, 2010 at 11:58 AM
Brett (I would if I could) - can you update the "Affects Version/s" field to see if this helps to get some attention on this?
Brett Wooldridge September 8, 2010 at 4:23 AM
This is still not fixed 3.5 after this bug was opened.
Tim Vollmer March 12, 2008 at 6:10 AM
As one quick and dirty method, you can add an insert statement to your import.sql file. For the value, use the desired initialValue divided by the allocationSize. For an initialValue of 1000, using an allocationSize of 50, use 20.
insert into hibernate_sequences (sequence_name, sequence_next_hi_value) values ('yourTableName', 20)
uweu December 28, 2007 at 3:03 PM
Is there already any kind of workaround? I need to set a lower limit to the generated IDs because of using Data from a legacy DB.
I would like to have generated IDs for a certain entity type start at the value of 1000.
Consider the following example.
@TableGenerator(name = "employee",
table = "SEQUENCES",
pkColumnName = "name",
valueColumnName = "value",
pkColumnValue = "employee",
allocationSize = 10,
initialValue = 1000)
Hibernate generates the SEQUENCES table correctly but it always returns 1 as the first generated key.
In the source code of AnnotationBinder.java which seems to be responsible for binding the @TableGenerator annotation to a MultipleHiLoPerTableGenerator instance the initialValue property is ignored.