Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 356256 - EclipseLink should insert new rows as necessary into empty @TableGenerator-specified tables
Summary: EclipseLink should insert new rows as necessary into empty @TableGenerator-sp...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-30 18:16 EDT by Laird Nelson CLA
Modified: 2022-06-09 10:10 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laird Nelson CLA 2011-08-30 18:16:49 EDT
Build Identifier: Eclipse Persistence Services - 2.2.0.v20110202-r8913

Suppose you create an empty sequence table following the requirements of the @TableGenerator annotation.  If you leave this table empty, and DDL generation is turned off, EclipseLink does not insert new rows in this sequence table as appropriate.

Both Hibernate and OpenJPA insert rows into such tables as necessary.  Hibernate has a bug where it ignores a @TableGenerator's initialValue attribute when it does so.  OpenJPA works flawlessly.

The JPA 2.0 specification is silent on this matter, but I would love it if EclipseLink would follow OpenJPA's lead here.

This is not DDL--this enhancement presumes the sequence table exists.  Consequently I regard any workaround that involves setting eclipselink.ddl-generation to any not "off" value to be a kludge.

Reproducible: Always

Steps to Reproduce:
1. Create a sequence table named "fred" with two columns following the structure implied by the @TableGenerator annotation specification.
2. Annotate an @Entity with a @TableGenerator that refers to "fred".
3. Start EclipseLink and persist an entity to this table.
4. Observe ECLIPSELINK-4011 raised because there are no rows in the table; hence no row to UPDATE.
Comment 1 Andrei Ilitchev CLA 2011-08-31 09:38:16 EDT
Workaround 1.
Use persistence unit property "eclipselink.ddl-generation" with "create-tables" value. 
Eclipselink attempts to create all mapped tables (pre-existing tables kept).
Then Eclipselink attempts to create sequence table(s) (pre-existing tables kept), then creates sequences in the db and populates sequence table(s).

Workaround 2.
EntityManager em = emf.createEntityManager();
ServerSession ss = em.unwrap(ServerSession.class);
(new SchemaManager(ss)).createSequences();
em.close();
Eclipselink attempts to create sequence table(s) (pre-existing tables kept), then creates sequences in the db and populates sequence table(s).
Comment 2 Jin Kwon CLA 2016-07-26 22:50:48 EDT
I'm still facing this problem. Is this normal or unnecessary by the spec?
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:10:28 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink