I have an application that utilizes Hibernate 4, where I use the TableHiLoGenerator strategy for identifier generation. Here's an example of how it's configured in Hibernate 4:
@Id
@GenericGenerator(name="audit-prop-table-generator", strategy="org.hibernate.id.TableHiLoGenerator",
parameters={@Parameter(value="hibernate_id_generation", name="table")})
@GeneratedValue(generator="audit-prop-table-generator")
@Column(name = "ID")
private int id;
and also:
@Type(type="java.lang.Long")
@Id
@Column(name="ID")
@GenericGenerator(name="default-table-generator", strategy="org.hibernate.id.TableHiLoGenerator",
parameters={@Parameter(value="hibernate_id_generation", name=TableHiLoGenerator.TABLE),
@Parameter(value="5000", name=TableHiLoGenerator.MAX_LO)})
protected T id;
In my database, I have a table named HIBERNATE_ID_GENERATION with a column NEXT_HI, which stores the next high value for the Hi/Lo algorithm.
Now, I'm planning to upgrade to Hibernate 5, and I'm wondering how to support this behavior in Hibernate 5. Additionally, I already have existing data in the HIBERNATE_ID_GENERATION table, so I need to ensure that the migration process preserves this data.
Could someone provide guidance on how to achieve this migration from Hibernate 4 to Hibernate 5 while preserving the behavior of the TableHiLoGenerator strategy and migrating existing data in the HIBERNATE_ID_GENERATION table? Any insights or examples would be greatly appreciated. Thank you!