-->
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: Hibernate sequence and allocation size
PostPosted: Wed Dec 08, 2010 5:19 am 
Newbie

Joined: Wed Nov 03, 2010 2:36 pm
Posts: 9
Hi.

I have application that runs on 2 nodes. Table uses sequence:
Code:
@SequenceGenerator(name = "GEN_ENTITY", sequenceName = "GEN_ENTITY", allocationSize = 4)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GEN_ENTITY")


When hibernate runs out of ids he gets next value from sequence and multiplies it by allocation size, then uses that "id pool" until he runs out again.
So, for example when we have 2 nodes and nextval = 1:
let's say node_A requested nextval first
node_A_id_pool = ids from 1 to 4
node_B_id_pool = ids from 4 to 8

And now here's my question.
How long that "id pool" is stored in memory?
If my hunch is right, that they are stored in memory until application is restarted, then there is no way to ensure that ids will be used in gradually incrementing manner? And the order in same table could be:
1 2 3 5 6 4 7 8

Are my assumptions correct? And is there a way to be sure that ids will be used gradually in one table when there are more than one application node?
I know that I could use allocationsize = 1, but that could impact performance if there are many objects to save...


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.