Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] Confused on Sequence and allocationSize

Hi Tim,

Sequencing is implemented such that EclipseLink will reserve the current
sequence number and the next X sequence numbers; X being the sequence
allocation size.  So if NextVal returns 50, EclipseLink calculates that the
current value was 50-x, and so it can now use numbers 50-x+1 up to 50 before
having to go to the database to allocate more.  Can't say exactly why 50 was
chosen as the default, though it seems to work well with table sequencing
which is also the default.  

Best Regards,
Chris

-----Original Message-----
From: eclipselink-users-bounces@xxxxxxxxxxx
[mailto:eclipselink-users-bounces@xxxxxxxxxxx] On Behalf Of Tim Hollosy
Sent: Friday, December 12, 2008 4:06 PM
To: EclipseLink User Discussions
Subject: [eclipselink-users] Confused on Sequence and allocationSize

So,
I am connecting to an oracle 9i DB.

I have a simple entity with a sequence based pk.

I added the annotations like so:

      @Id
	@SequenceGenerator(name="USER_PROFILE_SEQ",
sequenceName="REDACTED_USER_PROFILE_SEQ")
    @GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="USER_PROFILE_SEQ")

Every single insert the sequence used for the Pk seemed to be some
random number, smaller than the actual value of the sequence, even
though I could see the sequence being selected in the logs.

Then I noticed it was not random, but 50 minus the actual value of the
sequence. I remembered a post on this list about the default value for
allocationSize being 50, so i added an allocationSize=1 (to match my
sequence) to my @SequenceGenerator and we were back in business.

Now the question of the hour why was it subtracting 50 from the
sequence? EL apparantly does a nextval - (allocation size) on the
sequence (but not if the allocation size is 1?)

Also, why is the default value 50 to begin with?

Thanks!
Tim
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top