Community
Participate
Working Groups
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.
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).
I'm still facing this problem. Is this normal or unnecessary by the spec?
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink