Hi!

I have the following entities: LegalEntity (abstract), Person (inheriting
LegalEntity), Company (inheriting LegalEntity). I also have OneToMany
LegalEntity->Address (via addresses property) and both sides of relationship
use LAZY FetchType. Address can be "deactivated" (isActive set to true or
false).

I need to fetch LegalEntity with addresses collection filtered to contain
only Address entities which have isActive=true. I also must use FetchGroup
which references addresses from LegalEntity object.

If I use query:
- SELECT le FROM LegalEntity le LEFT JOIN FETCH le.addresses WHERE le.id=:id
AND le.addresses.isActive=true
I get correct LegalEntity (Company or Person) with all addresses (isActive
true or false).
If I use query:
- SELECT le, a FROM LegalEntity le JOIN le.addresses a WHERE le.id=:id AND
le.addresses.isActive=true
I also get correct LegalEntity with all addresses (because query contains
two joins with Address).
If I use query:
- SELECT le, a FROM LegalEntity le JOIN le.addresses a WHERE le.id=:id AND
a.isActive=true
I don't get any results because Person or Company are never used in executed
query. I get following message: Cannot instantiate abstract class of type
"entities.LegalEntity" with object id "4"; this may indicate that the
inheritance discriminator for the class is not configured correctly.

Is there a way to do this properly?

Thanks in advance.
-- 
View this message in context: 
http://openjpa.208410.n2.nabble.com/Abstract-class-Fetch-Join-tp5057450p5057450.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to