Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.2.2
-
None
-
None
-
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