[
http://opensource.atlassian.com/projects/hibernate/browse/ANN-635?page=co...
]
Adam Wozniak commented on ANN-635:
----------------------------------
Hello Emmanuel
Thanks for your answer.
OK, now I understand that this behavior is a "work as design". That is clear.
But I still think that it would be great to have such IdentifierGenerator (in *official*
Hibernate release) which can share sequence values between different classes.
My arguments:
* I think (and as far as I see) this is rather common pattern to share one sequence among
many tables
* such IdentifierGenerator would improve Hibernate based software with such sequences
Kind Regards,
Adam Woźniak
Hib doesn't share allocated sequence values between different
classes
---------------------------------------------------------------------
Key: ANN-635
URL:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-635
Project: Hibernate Annotations
Issue Type: Improvement
Affects Versions: 3.3.0.ga
Reporter: Adam Wozniak
Attachments: Zbbb.java, Zccc.java
Hello Everybody
This is my first issue here, so I don't know if my issue will be classified as a bug
or an improvement only.
My config:
hibernate-3.2.4.sp1
hibernate-annotations-3.3.0.GA
hibernate-entitymanager-3.3.1.GA
I use Oracle database. I have 2 entity classes (Zbbb and Zccc).
Those 2 classes map two database table: ZBBB and ZCCC.
Both tables have identical structure:
ID - NUMBER (primary key)
TEXT - VARCHAR2(10)
Identifiers for both tables are generated by _ONE_ (the same) Oracle sequence.
For both entities I have following annotations:
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"my_generator")
@javax.persistence.SequenceGenerator(
name = "my_generator"
, sequenceName = "SEQ_DEPT"
, allocationSize=2)
Note, that allocationSize is set: 2.
When I am creating and persisting 2 Zbbb and 2 Zccc entities like this:
{ Zccc entity = new Zccc(); em.persist(entity); } // DB HIT!
{ Zccc entity = new Zccc(); em.persist(entity); }
{ Zbbb entity = new Zbbb(); em.persist(entity); } // DB HIT!
{ Zbbb entity = new Zbbb(); em.persist(entity); }
... everything is OK because I have 2 hits to database sequence only.
But when I am creating and persisting 1 Zbbb and 3 Zccc entities like this:
{ Zbbb entity = new Zbbb(); em.persist(entity); }
{ Zccc entity = new Zccc(); em.persist(entity); }
{ Zccc entity = new Zccc(); em.persist(entity); }
{ Zccc entity = new Zccc(); em.persist(entity); }
... I have 3 hits do database sequence.
I would expect, that Hibernate should recognize that Zbbb and Zccc are suing the same
database sequence and should share all cached values between entities of those two
classes.
Do I do something wrong?
Kind regards,
Adam Wozniak
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira