users@glassfish.java.net

Re: JPA: Polymorphic Queries

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Jan 2009 09:17:15 PST

I know the parent post is over a year old, but in case anyone is searching old posts:

I believe you would have to either copy the query to a new one which uses the subclass, or somehow query for the subclass discriminator column (using .class?). In other words, the caller would choose what subclass by setting the discriminator as a parameter. I'm not 100% sure if the second method works or not (I have had mixed results depending on which O-R framework and which version), but if it does work then that would be more concise than creating a whole new query. If it does not work then you could build the query dynamically passing the MySubclass.class to a DAO method.

Also, according to JPA documentation the query should be polymorphic regardless of the inheritance strategy used. Is this true?

If anyone has any input on this, please post...
[Message sent by forum member 'josephhitt' (josephhitt)]

http://forums.java.net/jive/thread.jspa?messageID=324321