persistence@glassfish.java.net

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

From: Pramod Gopinath <Pramod.Gopinath_at_Sun.COM>
Date: Tue, 28 Mar 2006 10:35:16 -0800

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