2

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?

4

1 回答 1

4

'prefer_sequence_per_entity' 直到 4.1.3 才添加(参见https://hibernate.atlassian.net/browse/HHH-6790)。上面你澄清说你使用的是 4.0。您需要升级才能使用它,或者复制 4.1.3 版本的 SequenceStyleGenerator

于 2013-09-23T19:57:02.110 回答