-->
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: Oracle sequences and allocationSize
PostPosted: Thu Jun 09, 2011 3:50 pm 
Newbie

Joined: Mon May 09, 2011 10:47 pm
Posts: 2
Hi,

We'd like the application to retrieve a block of IDs from an Oracle sequence and reuse those rather than hit the DB each time to get the sequence value.

We have the ID annotated as follows:

@Id
@Column(name="MY_ID", nullable=false, insertable=true, updatable=false)
@SequenceGenerator(name="planIdSequence", sequenceName="MY_ID_SEQ", allocationSize=50)
@GeneratedValue(strategy=GenerationType.AUTO, generator="planIdSequence")
private Long id;

And the sequence in Oracle created as:

create sequence MY_ID_SEQ start with 1 increment by 50 cache 20 nocycle;

However, I'm noticing that each insert into the DB, the ID value is being set to +50. As though it's still going to the DB for each request. Does the allocationSize only work on a per session basis? The service has multiple hosts and multiple threads per host - so if the allocationSize only applies per session and we commit/close after each requests - that would at least explain the behaviour we are seeing.

If that is the case, is there a way to have this applied at a global level, per service instance across multiple threads rather than per session? Another alternative could be to write a custom sequence generator that allows us to do this on an application instance level.

Any help is greatly appreciated,
Thanks!


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.