Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333131

Summary: initialValue of TableGenerator actions correctlly?
Product: z_Archived Reporter: zhao jianyong <zjy.net>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description zhao jianyong CLA 2010-12-23 02:09:30 EST
JSR 317: JavaTM Persistence API, Version 2.0
11.1.46 TableGenerator Annotation

TableGenerator Annotation Elements:
================================================================================
Type  Name                Description                                     Default
int   initialValue    (Optional) The value used to initialize the            0
                      column that stores the last value generated.
================================================================================

So I think initialValue of TableGenerator is the last value stored in DB,
and the first number generated should be initialValue + 1.

----------------------------------------------------------------------
Example:
----------------------------------------------------------------------
@TableGenerator(name="SEQ_GEN", table="OTHER_SEQ_GEN", 
                pkColumnName="OTHER_SEQ_NAME",    valueColumnName="OTHER_SEQ_GEN",
                pkColumnValue="OTHER_SEQ_COUNT",  initialValue=50, 
                                                  allocationSize=10)

current SQL:
INSERT INTO OTHER_SEQ_GEN(OTHER_SEQ_NAME, OTHER_SEQ_GEN) values ('OTHER_SEQ_COUNT', 49) 

current first number generated: 50

right  SQL:
INSERT INTO OTHER_SEQ_GEN(OTHER_SEQ_NAME, OTHER_SEQ_GEN) values ('OTHER_SEQ_COUNT', 50)

right  first number generated: 51
Comment 1 Tom Ware CLA 2011-01-07 13:48:39 EST
As designed.  initialValue is "the initial value".  That is exactly what is described above.
Comment 2 Eclipse Webmaster CLA 2022-06-09 10:31:49 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink