| Summary: | NPE occurs on specifying two kinds of primary key generators on orm.xml | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Masumi Ito <masumii> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | CLOSED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P2 | CC: | eclipselink.orm-inbox, masumii, nan.n.li, tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Whiteboard: | submitted_patch | ||||||||
| Attachments: |
|
||||||||
Created attachment 199465 [details]
Reproducible application
The reason of this issue is to call getPkColumnValue() in MetadataProject class without checking null.
public void addSequenceGenerator(SequenceGeneratorMetadata sequenceGenerator, String defaultCatalog, String defaultSchema) {
...
if ((tableGenerator != otherTableGenerator) && (otherTableGenerator.getPkColumnValue() != null) && otherTableGenerator.getPkColumnValue().equals(sequenceGenerator.getSequenceName())) {
}
...
}
According to JPA2.0 spec, pkColumn Value is optional, so it is sometimes omitted.
Created attachment 199466 [details]
Patch for this issue
Attached a patch based on EclipseLink 2.2.0.v20110202-r8913.
About the attached patch: Because MappedSuperclassAccessor#process() always calls processSequenceGenerator() after calling processTableGenerator(), MetadataProject#addTableGenerator() doesn't seem to throw NPE. However potentially addTableGenerator() also has similar issue in terms of optional SequenceName of SequenceGenerator. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. Assigning to myself with the goal of checking the supplied patch. Looking at including patch in 2.3.1 Fixed in 2.3.1 and trunk. Patch submitted as-is. Added testing to our XML-only model through modification of the metadata files. No specific test added. Regressions will show up if deployment fails on test model. Reviewed by: Tom Ware reviewed user submitted fix Tested with JPA LRG *** Bug 331956 has been marked as a duplicate of this bug. *** The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: When defining both SequenceGenerator and TableGenerator on orm.xml, NullPointerException occurs on building its metadata if pkColumnValue of the TableGenerator is not specified. EX) orm.xml <sequence-generator name="SEQ_GEN" allocation-size="1"/> <table-generator name="TBL_GEN" table="NAME_TBL"/> <attributes> <id name="id"> <generated-value strategy="SEQUENCE" generator="SEQ_GEN"/> </id> </attributes> EX) StackTrace of NPE Internal Exception: java.lang.NullPointerException at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1127) at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:187) at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:205) at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:119) at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:214) at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:483) at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:221) at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:167) ... Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Predeployment of PersistenceUnit [pu1] failed. Internal Exception: java.lang.NullPointerException at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:210) ... 62 more Caused by: java.lang.NullPointerException at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.addSequenceGenerator(MetadataProject.java:630) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.processSequenceGenerator(MappedSuperclassAccessor.java:1237) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.MappedSuperclassAccessor.process(MappedSuperclassAccessor.java:655) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:599) at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1541) at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:485) at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:454) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1081) Although this issue was originally detected when deploying a JPA2.0 app on GlassfishV3.2(EclipseLink2.2), the latest version of EclipseLink also seems to have same issue. Reproducible: Always