-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Sequence is not generating id numbers in order
PostPosted: Tue Mar 14, 2017 11:56 am 
Newbie

Joined: Tue Mar 14, 2017 11:13 am
Posts: 1
We are using Hibernate 4.0.0 version with Oracle 12c database and we are using Sequence Generation for our ids. But the sequence generator is not generating the ids in continuous order. It is generating in random order. Due to this we have to increase column length from 3 to 5.

@Id
@Column(name = C_XXXXX)
@SequenceGenerator(name = SEQUENCE_XXX, sequenceName = SEQUENCE_XXX)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SEQUENCE_XXX)
private long someId;


Our Sequence Parameters:
MIN_VALUE 1
MAX_VALUE 99999999
INCREMENT_BY 1
CYCLE_FLAG N
ORDER_FLAG N
CACHE_SIZE 20
LAST_NUMBER 81
PARTITION_COUNT
SESSION_FLAG N
KEEP_VALUE N


Top
 Profile  
 
 Post subject: Re: Hibernate Sequence is not generating id numbers in order
PostPosted: Tue Mar 14, 2017 2:56 pm 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
The database sequence is a non-transactional sequence generator, so values are not guaranteed to be consecutive because one transaction might just roll back a given SQL INSERT.

The only requirement is that sequences need to be monotonically increasing, and that's how it should work. So, the values are not assigned randomly at all. It's just that gaps are not an issue at all.


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

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.