Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » JPA query with hierarchy
JPA query with hierarchy [message #666422] Wed, 20 April 2011 08:23 Go to next message
Eclipse UserFriend
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 10:01 Go to previous message
Eclipse UserFriend
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.

Previous Topic:Transfer entities between entitymanagers
Next Topic:Error On ScrollableCurosr
Goto Forum:
  


Current Time: Tue Jul 22 11:42:00 EDT 2025

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

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

Back to the top