Issue Details (XML | Word | Printable)

Key: OPENJPA-314
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Dain Sundstrom
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenJPA

Unenhanced complex id in MappedSuperclass causes NPE

Created: 14/Aug/07 05:34 PM   Updated: 13/May/09 10:06 PM
Return to search
Component/s: UnenhancedClasses
Affects Version/s: None
Fix Version/s: 1.0.0

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works OPENJPA-314.patch 2007-08-14 05:35 PM Dain Sundstrom 7 kB
Issue Links:
Blocker
 

Resolution Date: 20/Aug/07 11:19 PM


 Description  « Hide
When I have a complex id within an unenhanced MappedSuperClass, I get a NPE when calling persist. The NPE appears to be caused because ClassMetaData.getField(int) does not take unenhanced MappedSuperclass fields into account. Here is the stack trace:

<openjpa-0.0.0-r420667:564688M nonfatal general error> org.apache.openjpa.persistence.PersistenceException: null
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2437)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2251)
at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1010)
at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541)
at org.apache.openjpa.enhance.TestUnenhancedCompoundPKSubclass.compoundPKHelper(TestUnenhancedCompoundPKSubclass.java:46)
at org.apache.openjpa.enhance.TestUnenhancedCompoundPKSubclass.testCompoundPKFieldAccessUserDefined(TestUnenhancedCompoundPKSubclass.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
Caused by: java.lang.NullPointerException
at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(ApplicationIds.java:568)
at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchIntField(ApplicationIds.java:537)
at org.apache.openjpa.enhance.org$apache$openjpa$enhance$UnenhancedCompoundPKFieldAccessSubclass$pcsubclass.pcCopyKeyFieldsToObjectId(Unknown Source)
at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:160)
at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:185)
at org.apache.openjpa.enhance.ReflectingPersistenceCapable.pcNewObjectIdInstance(ReflectingPersistenceCapable.java:257)
at org.apache.openjpa.util.ApplicationIds.create(ApplicationIds.java:384)
at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2405)
... 23 more

Attached is a test case that reproduces the NPE. The test methods have been disabled as to not break the build.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dain Sundstrom made changes - 14/Aug/07 05:35 PM
Field Original Value New Value
Attachment OPENJPA-314.patch [ 12363791 ]
Dain Sundstrom made changes - 14/Aug/07 10:59 PM
Link This issue blocks OPENEJB-628 [ OPENEJB-628 ]
Patrick Linskey made changes - 20/Aug/07 11:18 PM
Comment [ This patch is the same as the one for OPENJPA-314, right down to the name. Is that expected? ]
Patrick Linskey made changes - 20/Aug/07 11:19 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Michael Dick made changes - 13/May/09 10:06 PM
Component/s jpa [ 12311304 ]
Component/s UnenhancedClasses [ 12312835 ]