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

Well, the problem is that I must start with the A-Class. I cannot start from
the C class; I query on A, then over the collection to B which then has C
and D as subclasses. The properties of the classes C and D are
"unreachable", so to speak.

Anyway, currently I am using an IN plus subquery to get the things done, but
it is not as nice and maybe (?) slower. I do something like A->B.id IN
(select id from C where C.properties = ...). I add the class C dynamically,
so it could be also D, E, etc.

Greets,
Jan


Gordon Yorke-2 wrote:
> 
> 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.
>>>
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Expression%2C-joins-and-inheritance-tp22804915p22842935.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top