You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by jeff <je...@yahoo.com> on 2007/03/16 23:01:50 UTC

find()'ing an abstract class

class B extends A
A is abstract
B is concrete

i have persisted an instance of B. now i try:

A a = em.find(A.class, anId);

openjpa fails with:

... Cannot create new application identity instance for abstract class "class A"

if i change the find to:

A a = em.find(B.class, anId);

openjpa works okay.
 
this isn't a big deal, but i'd expect the find() on the abstract class to work, because it seems like a mistake to expect the caller to know the implementation of the class in order to fetch it, if all they know about is the abstract class.

for what it's worth, this test does work w/ toplink. 

thoughts?



 
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

Re: find()'ing an abstract class

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi Jeff,

If you've defined the id field or property in Entity class A, then  
this should work. If not, file a JIRA issue, upload a failing test  
case, and upload a fix, if you don't mind. ;-)

Craig

On Mar 16, 2007, at 3:01 PM, jeff wrote:

> class B extends A
> A is abstract
> B is concrete
>
> i have persisted an instance of B. now i try:
>
> A a = em.find(A.class, anId);
>
> openjpa fails with:
>
> ... Cannot create new application identity instance for abstract  
> class "class A"
>
> if i change the find to:
>
> A a = em.find(B.class, anId);
>
> openjpa works okay.
>
> this isn't a big deal, but i'd expect the find() on the abstract  
> class to work, because it seems like a mistake to expect the caller  
> to know the implementation of the class in order to fetch it, if  
> all they know about is the abstract class.
>
> for what it's worth, this test does work w/ toplink.
>
> thoughts?
>
>
>
>
> ---------------------------------
> Never miss an email again!
> Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!