openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "C N Davies" <...@cndavies.com>
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.

Chris



-----Original Message-----
From: vld [mailto:knezevicvladimir@yahoo.com] 
Sent: Saturday, 15 May 2010 8:19 AM
To: users@openjpa.apache.org
Subject: Abstract class Fetch Join


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-tp5057450p5057
450.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message