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

Bug 311328

Summary: @SequenceGenerator initialValue on eclipselink.ddl-generation is ignored
Product: z_Archived Reporter: Yohan Yudanara <yohan_y>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P2 CC: eclipselink.orm-inbox, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard: submitted_patch
Attachments:
Description Flags
Suggested patch (without test). none

Description Yohan Yudanara CLA 2010-05-02 22:11:40 EDT
Build Identifier: 

Library: JPA 2.0 on Glassfish v3.0.
Database & JDBC: Postgresql 8.4 and postgresql-8.4-701.jdbc4 
JDK & OS: JDK 6 and Vista Home Basic.

When I'm using initialValue on @SequenceGenerator annotation and use
eclipselink.ddl-generation (create-tables) on persistence.xml, the
generated sequence always ignore the initialValue attribute.

This is my annotation:
@SequenceGenerator(name="RoleSeq",sequenceName="seq_role",initialValue=100000)

And this is the generated sequence: (start value is always *50*, not *100000*)
CREATE SEQUENCE seq_role
 INCREMENT 50
 MINVALUE 1
 MAXVALUE 9223372036854775807
 START *50*
 CACHE 1;

Reproducible: Always

Steps to Reproduce:
1. create sequence generator annotation on entity class:
@SequenceGenerator(name="RoleSeq",sequenceName="seq_role",initialValue=10000)
2. use ddl-generation on persistence.xml:
<property name="eclipselink.ddl-generation" value="create-tables"/>
3. run glassfish to make ddl running
Comment 1 Andrei Ilitchev CLA 2010-05-03 10:25:51 EDT
Created attachment 166779 [details]
Suggested patch (without test).

Note that initialValue indicates the first sequence value that the app. will use - not the start value of the sequence in the db.

If initialValue = 10000 and allocationSize = 50 the generated sequence will look like:
CREATE SEQUENCE seq_role
INCREMENT 50
START 10049

The first sequence value to be used by the app is 10049 - 50 + 1 = 10000.
Comment 2 Tom Ware CLA 2010-05-13 09:54:20 EDT
Setting target and priority.  See the following page for details of what these
values mean.

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 3 Tom Ware CLA 2010-06-11 15:35:32 EDT
suggested patch is already included in 2.1 - my tests indicate this functionality works with the patch
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:25:04 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink