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

Merge operation fails with IdClass composite key

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.0.2
    • Fix Version/s: 1.0.4, 1.2.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Description

      I've tried to use composite keys through the IdClass annotation, but the merge operation fails with the following error. I used the ApplicationIdTool to generate the IdClass object. What's odd is that I can take that exact same code and just switch the logic to use the Embeddable/EmbeddedId annotations and the merge command works.

      Exception in thread "main" <openjpa-1.0.2-r420667:627158 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: The given value "idclass.CvssVector-1.0::Base" cannot be converted into an identity for "class idclass.CvssVector". The value is the wrong type (org.apache.openjpa.util.ObjectId).
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1094)
      at org.apache.openjpa.kernel.VersionAttachStrategy.findFromDatabase(VersionAttachStrategy.java:372)
      at org.apache.openjpa.kernel.VersionAttachStrategy.attach(VersionAttachStrategy.java:77)
      at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:241)
      at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:101)
      at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3160)
      at org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1142)
      at org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:665)
      at idclass.TestSave.main(TestSave.java:41)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
      Caused by: java.lang.ClassCastException: org.apache.openjpa.util.ObjectId
      at idclass.CvssVector.pcCopyKeyFieldsToObjectId(CvssVector.java)
      at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:160)
      at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:195)
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1087)
      ... 13 more

        Attachments

        1. test.zip
          4.24 MB
          Chadwick M Baatz

          Activity

            People

            • Assignee:
              ppoddar@apache.org Pinaki Poddar
              Reporter:
              cbaatz Chadwick M Baatz
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: