Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-314

Unenhanced complex id in MappedSuperclass causes NPE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0.0
    • UnenhancedClasses
    • None

    Description

      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.

      Attachments

        1. OPENJPA-314.patch
          7 kB
          Dain Sundstrom

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dain Dain Sundstrom
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: