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

Bad error message for find of an Entity with compound primary key if parameter of wrong class

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.0-M2
    • 2.0.0-M3
    • kernel
    • None

    Description

      Test set: com.mysql.clusterj.openjpatest.LongLongStringPKRelationshipTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.234 sec <<< FAILURE!
      test(com.mysql.clusterj.openjpatest.LongLongStringPKRelationshipTest) Time elapsed: 4.168 sec <<< ERROR!
      <openjpa-1.2.0-r422266:753657 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: 1
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1154)
      at org.apache.openjpa.kernel.DelegatingBroker.newObjectId(DelegatingBroker.java:268)
      at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:451)
      at com.mysql.clusterj.openjpatest.LongLongStringPKRelationshipTest.test(LongLongStringPKRelationshipTest.java:65)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
      at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.retrieve(ApplicationIds.java:602)
      at org.apache.openjpa.util.ApplicationIds$PrimaryKeyFieldManager.fetchLongField(ApplicationIds.java:578)
      at com.mysql.clusterj.jpatest.model.LongLongStringFKRelationship.pcCopyKeyFieldsToObjectId(LongLongStringFKRelationship.java)
      at org.apache.openjpa.enhance.PCRegistry.copyKeyFieldsToObjectId(PCRegistry.java:172)
      at org.apache.openjpa.util.ApplicationIds.fromPKValues(ApplicationIds.java:218)
      at org.apache.openjpa.kernel.BrokerImpl.newObjectId(BrokerImpl.java:1141)
      ... 30 more

      The failure is clearly a user error but the message is bad. The message should say that the type of the argument doesn't match the metadata for the class.

      The failing line of code is:
      LongLongStringFKRelationship b = em.find(LongLongStringFKRelationship.class, i);

      The correct code is:
      LongLongStringFKRelationship b = em.find(LongLongStringFKRelationship.class, new LongLongStringOid);

      Attachments

        Issue Links

          Activity

            People

              clr Craig L Russell
              clr Craig L Russell
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: