Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA query with hierarchy
JPA query with hierarchy [message #666422] Wed, 20 April 2011 12:23 Go to next message
moloco  is currently offline moloco
Messages: 7
Registered: March 2010
Junior Member
Sorry for my bad EN Embarrassed

I have class hierarchy (JOINED) for example

class A { field a }

class B extends A { field b }
class C extends A { field c }

how can i get all objects filtered by fields a,b,c

in SQL it very simple

select * from A
left join B on ...
left join C on ...
where A.a = ... or B.b = .... or C.c = .....

how in JPQL ??
Re: JPA query with hierarchy [message #666670 is a reply to message #666422] Thu, 21 April 2011 14:01 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

EclipseLink has a TREAT keyword that allows casting to a subclass, but it is more for accessing a relationship, not the root class,

i.e.

Select e from Employee e join TREAT(e.projects AS LargeProject) lp where lp.budget = value

I think you would need to execute multiple queries in JPQL, one for each subclass you want to query something on.

Otherwise you can use a native SQL query.

I think the issue is similar to,

https://bugs.eclipse.org/bugs/show_bug.cgi?id=312146

So you may wish to add your requirements to that bug and vote for it.



James : Wiki : Book : Blog : Twitter
Previous Topic:Transfer entities between entitymanagers
Next Topic:Error On ScrollableCurosr
Goto Forum:
  


Current Time: Sat Oct 25 00:04:40 GMT 2014

Powered by FUDForum. Page generated in 0.01540 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software