persistence@glassfish.java.net

Re: Question about code in StandardSequence.createVector() related to a posting in GF Discussion Forum

From: Andrei Ilitchev <andrei.ilitchev_at_oracle.com>
Date: Tue, 28 Mar 2006 14:11:20 -0500

The check safeguards from the following situation: in the db Oracle sequence
is defined with increment = 1; but specifies sequence with
allocationSize=50.
Correct setup: sequence increment in the db and allocationSize in Java
should be the same.

Thanks,

Andrei

----- Original Message -----
From: "Pramod Gopinath" <Pramod.Gopinath_at_Sun.COM>
To: "Tom Ware" <tom.ware_at_oracle.com>; "Gordon Yorke"
<gordon.yorke_at_oracle.com>; "Andrei Ilitchev" <andrei.ilitchev_at_oracle.com>;
<persistence_at_glassfish.dev.java.net>
Sent: Tuesday, March 28, 2006 1:35 PM
Subject: Question about code in StandardSequence.createVector() related to a
posting in GF Discussion Forum


> Hi Andrei/Tom/Gordon
> This question has arisen based on a posting in the Glassfish discussion
> forum :
> http://forums.java.net/jive/thread.jspa?threadID=14185&tstart=0
>
> If the user has defined an allocation size < 50 in their entity class,
> then we would get an exception from the toplink code. The complete stack
> trace is present in the discussion forum posting. I am listing just the
> top few lines :
> Caused by: Exception [TOPLINK-7027] (Oracle TopLink Essentials - 2006.3
> (Build 060324)): oracle.toplink.essentials.exceptions.ValidationException
> Exception Description: The sequence named [CHANNEL_SEQ] is setup
> incorrectly. Its increment does not match its pre-allocation size.
> at
> oracle.toplink.essentials.exceptions.ValidationException.sequenceSetupIncorrectly(ValidationException.java:1278)
> at
> oracle.toplink.essentials.sequencing.StandardSequence.createVector(StandardSequence.java:149)
> at
> oracle.toplink.essentials.sequencing.StandardSequence.getGeneratedVector(StandardSequence.java:85)
>
>
> I was looking at the code in
> oracle.toplink.essentials.sequencing.StandardSequence.createVector() lines
> 144 through 150 and had a question about this code.
>
> Why do we have the following check in the code
> nextSequence = nextSequence.subtract(new BigDecimal(size));
>
> This code would always return a value < 0 if the allocation size specified
> by the user is less than the default allocation size (50) defined in
> Sequence.java.
>
> Why is this check there in the code.
>
> Thanks
> Pramod
>