-->
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: Problem with sequence generation in Oracle9i Hibernate3 env.
PostPosted: Tue Sep 09, 2008 4:38 pm 
Newbie

Joined: Tue Sep 09, 2008 3:50 pm
Posts: 4
Location: Minneapolis
This involves sequence generation in an Oracle 9i / Hibernate3 (hibernate3.jar) environment. The allocationSize attribute of the SequenceGenerator annotation is acting as a multiplier instead of an incrementer. That is, if the last_number field of a sequence is 100,000, upon first usage hibernate is generating id values that begin at 50 * 100000 or 5000000 (i.e. 5000001, 5000002, 5000003,...). The "50" value is the default value for the allocationSize attribute, so the above behavior occurs with no allocationSize attribute set. If I specify "allocationSize=1" in the SequenceGenerator, then the ids that are generated are incremented beginning at 100000 (i.e. 100001, 100002, 100003, ...). The later is an over simplification as it would be more correct to say (for example) if last_number was 100020 (cache_size = 20), then the ids that are generated are incremented beginning at 100000 (i.e. 100001, 100002, 100003, ...) (for example).

I am posting this in the event someone else encounters the issue. My searches failed to locate the above symptoms (and therefore any fix). The following is an example of the annotations there were used. I should indicate that I do not rely on any triggers or "code" for sequence generation, only the following annotations:

In the "@MappedSuperclass" I have:

@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="acctNbr")
@Column(name="ACCT_NBR", unique=true, nullable=false, insertable=true, updatable=true, precision=22, scale=0)
public Long getAcctNbr() {
return this.acctNbr;
}

In the associated concrete class I have:

@Entity
@SequenceGenerator(name="acctNbr", sequenceName="ACCTNBR", allocationSize=1)
@Table(name="ACCOUNT",schema="OCH", uniqueConstraints = {})
public class Account extends AbstractAccount implements java.io.Serializable { ...


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.