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

EntityManager.find ClassCastException for wrong but existing id

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: kernel
    • Labels:
      None
    • Environment:
      Windows 7, jdk 1.7.0_45 64 bit

      Description

      I have base entity and 2 inheritors e.g. Person and Document.
      If I try to find Person entity and provide id of the Document entity like

      Person p = em.find(Person.class, document.getId());

      I get

      java.lang.ClassCastException: org.apache.openjpa.find.entities.Document cannot be cast to org.apache.openjpa.find.entities.Person
      at org.apache.openjpa.find.FindTest.testFind(FindTest.java:54)

      but it should return either null or EntityNotFoundException.

      If I provide just some wrong non existing id I get null.

      The maven project with test is attached to the issue.
      Original discussion: http://openjpa.208410.n2.nabble.com/EntityManager-find-ClassCastException-for-wrong-but-existing-id-td7587085.html

        Attachments

        1. openjpa-find-test.zip
          7 kB
          Oleg Lyalikov

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              oleg.lyalikov Oleg Lyalikov
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: