Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EntityManager.find returning instance of wrong type

I think you are correct, it should return null if the class is wrong (not an
instanceof the class), please log a bug for this.

For now, either catch the ClassCastException, or query the Base class or
Bar.


jsw wrote:
> 
> I don't understand why JPA is searching through objects of type Bar when I
> specifically ask for an object of type Foo. I would expect JPA to notice
> that the type does not match even though the id does and return null
> instead of simply trying to cast. (Or better yet, not bother to sift
> through objects of the wrong type.) Somebody might be trying to do what I
> did ;-)
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/EntityManager.find-returning-instance-of-wrong-type-tp22367490p22413667.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top