I am working on a requirement where we need to use sequence per entity.
Right now I have created a table hibernate_sequence
with columns and values as below:
next_value | sequence_name
-----------|--------------
100000045 |
100050000 | ACCOUNT_SEQ
Following is my hbm.xml
file for entity ACCOUNT
:
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator">
<param name="prefer_sequence_per_entity">true</param>
<param name="optimizer">none</param>
<param name="increment_size">1</param>
</generator>
But somehow my inserts using global sequence id instead of using sequence defined for ACCOUNT. Can somebody please point out what I am doing wrong here?
I did refer Steve answer for this question, but hibernate documentation is not clear on how to use this feature. Should we have a separate table for each entity (or) same table with different rows per each entity with some well-defined syntax?