Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Expression, joins and inheritance

You may have missed James' point "You can also do this using a parallel _expression_, but it will cause an extra join."

You could write something like
ExpressionBuilder subClass = new ExpressionBuilder("C");
expressionBuilder.get("b").equal(subClass).and(subClass.get("C_Prperty").equal("bob"));

--Gordon


ossaert wrote:
Thanks for the hint. It also crossed my mind, but since I do not know how
much subclasses there will be at compile time of the base-class B, I cannot
use this strategy. I.e. I cannot add OneToOne to the base-class for every
subclass. Suppose I have 20, then I have a lot of properties to add :-(.

Greetings
Jan


James Sutherland wrote:
  
EclipseLink does not currently have support for casting in an _expression_
or JPQL, so please log an enhancement request for this.  However it is
possible to do this using a QueryKey.

In your ClassDescriptor for A define a OneToOneQueryKey "myC" that
reference the C class, and uses the same foreign key join as to B.  You
can also define one to D.  Then in your query when you want to query on C
access the new query key "myC" instead of "myB".

i.e.
expressionBuilder.get("myC").get("cProperty")

You can also do this using a parallel _expression_, but it will cause an
extra join.



    
  

Back to the top