Community
Participate
Working Groups
Build Identifier: 20100917-0705 If generators with the same name are defined in both the java entity and the mapping XML, the one defined in the mapping XML will override the one in the java entity regardless the level and type so there should be no exception thrown when running the application. However, exception like the following will be thrown when doing so: Exception in thread "main" Local Exception Stack: Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@1ef6a746 Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [DaliRuntimeProj] failed. Internal Exception: Exception [EclipseLink-7238] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.ValidationException Exception Description: The table generator specified in [class test.oracle.models.employee.Foo2] with name == [GEN] conflicts with the sequence generator with the same name specified in [file:/D:/Oracle/dali.test/workspace/DaliRuntimeProj/build/classes/META-INF/orm.xml]. at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:126) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:133) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source) at dali.runtim.Runtime.main(Runtime.java:14) Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [DaliRuntimeProj] failed. Internal Exception: Exception [EclipseLink-7238] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.ValidationException Exception Description: The table generator specified in [class test.oracle.models.employee.Foo2] with name == [GEN] conflicts with the sequence generator with the same name specified in [file:/D:/Oracle/dali.test/workspace/DaliRuntimeProj/build/classes/META-INF/orm.xml]. at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1005) at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:88) at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:124) ... 4 more Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [DaliRuntimeProj] failed. Internal Exception: Exception [EclipseLink-7238] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.ValidationException Exception Description: The table generator specified in [class test.oracle.models.employee.Foo2] with name == [GEN] conflicts with the sequence generator with the same name specified in [file:/D:/Oracle/dali.test/workspace/DaliRuntimeProj/build/classes/META-INF/orm.xml]. at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 7 more Caused by: Exception [EclipseLink-7238] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.ValidationException Exception Description: The table generator specified in [class test.oracle.models.employee.Foo2] with name == [GEN] conflicts with the sequence generator with the same name specified in [file:/D:/Oracle/dali.test/workspace/DaliRuntimeProj/build/classes/META-INF/orm.xml]. at org.eclipse.persistence.exceptions.ValidationException.conflictingSequenceAndTableGeneratorsSpecified(ValidationException.java:2178) at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.addTableGenerator(MetadataProject.java:632) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.processTableGenerator(MappedSuperclassAccessor.java:1360) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.processClassMetadata(MappedSuperclassAccessor.java:885) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:684) at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1497) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:474) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:441) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:959) ... 6 more Reproducible: Always Steps to Reproduce: 1. Define a table generator named as GEN at the entity level in the Java entity 2. Define a sequence generator also named as GEN at the mapping file level in the mapping XML 3. Try to run the application Note: 1. Exception is also thrown when defining a sequence generator at the entity level in the Java entity while defining a table generator with the same name at the mapping file level or entity level in the mapping XML. 2. Same problem may exist in converters and queries.
Changing to Enhancement. We believe this is a grey-area in the specification. The spec indicates an override is required if sequence-generators are specified with the same name. It does not indicate what should occur is a sequence-generator and a table-generator have the same name. Community: Please vote (and add comments) to this bug if you feel there should be an override. Please add comments, if you think the current behavior is correct.
While the spec is vague on this, I think the JPA 2 book is pretty clear with the example on page 382 that shows a @SequenceGenerator annotation with a table-generator xml element overriding it.
Reminder: If you want this enhancement please ensure you Vote for it.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink