It is possible to do an "UNION" in JPQL or something like this?
Because I have a abstract class ("Table a") which has 3 different subclass ("Table b", "Table c", "Table d") and when I execute my query I don't know in advance what kind of subclass I need.
The variables varB, varC, varD represent the same field but with a different name.
I would like to retrieve an object A with my query
“SELECT a FROM A a, Other o JOIN FETCH a.other WHERE o.varOther like ‘…’”
In this case, if the user puts something in the search field “var” I need to add either varB, varC, or varD in the WHERE clause but I don’t know in advance if the type of the subclass is varB, varC or varD, I’m stuckeeeed!
I've got a "unknown state or association field [varB] of class […A]" by example
Joined: Oct 01, 2007
You might want to consider using a dynamic query, so depending on your argument, then decide which subclass to query.
If you need one query, then you may be able to use EclipseLink's "TREAT" function.