[ 
https://issues.apache.org/jira/browse/OPENJPA-2528?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17169703#comment-17169703
 ] 

chenlin commented on OPENJPA-2528:
----------------------------------

Hi, Oleg 
after looking at your test cases, I find that the parent class BaseEntity you 
defined,  

@Id  
@GeneratedValue 
 protected String id; 

Modified: protected String id; --> Protected Integer id; 
Maybe you can test 

> 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
>            Priority: Major
>         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
(v8.3.4#803005)

Reply via email to