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 { ...
|