Oleg Lyalikov created OPENJPA-2528:
--------------------------------------

             Summary: EntityManager.find ClassCastException for wrong but 
existing id
                 Key: OPENJPA-2528
                 URL: https://issues.apache.org/jira/browse/OPENJPA-2528
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 2.2.2
         Environment: Windows 7, jdk 1.7.0_45 64 bit
            Reporter: Oleg Lyalikov
         Attachments: openjpa-find-test.zip

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



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to