-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to share IdentifierGenerator between entities ?
PostPosted: Fri Aug 09, 2013 4:43 pm 
Newbie

Joined: Tue Nov 21, 2006 6:50 pm
Posts: 3
I have a unique Oracle sequence in my schema, used to draw primary keys for several tables.
I mapped this scenario to JPA/Hibernate by declare a @SequenceGenerator on a package-info.java so that it's available for the whole persistence-unit, then my entities reference the generator by name using @GeneratedValue

I'm using an allocationSize=100 with the enhanced generators and pooled-lo optimizer.

It seems that Hibernate actually creates an instance of SequenceStyleGenerator for each entity, so that in the end when 2 different entities are inserted, 2 DB calls are made instead of one because there are 2 instances of the PooledLoOptimizer.

The same java code run with EclipseLink actually shares the generator : the DB is accessed only once.

Is there a way to share generator instances with Hibernate ? It seems that it was not the case back in 2007 (see this post https://forum.hibernate.org/viewtopic.php?f=9&t=969596&hilit=shared+sequence ), what about now with 4.2 ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.