openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <>
Subject RE: Abstract class Fetch Join
Date Sat, 15 May 2010 08:08:02 GMT
I a have similar "Active" field on all my entities, I use "join fetch" not
"left join fetch" for the same purpose but don't have this issue.


-----Original Message-----
From: vld [] 
Sent: Saturday, 15 May 2010 8:19 AM
Subject: Abstract class Fetch Join


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

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
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 AND
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 AND
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:
Sent from the OpenJPA Users mailing list archive at

View raw message