[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Expression, joins and inheritance
|
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.
ossaert wrote:
>
> Hello,
>
> I want to build an expression which makes a query on an object A which has
> a foreign key to table B. However, B is the super-class of C and D. I wish
> to query the sequence A.B.property_of_C. This, however, does not function
> since B does not have the property of class C. This is probably a little
> bit abstract, so here is a snippet of my expression:
>
>
> // Determine reference class (B is the superclass, we select C or
> D which extends B)
> Class refClass = NodeTypeMapping.getClassByNodeType(..);
> System.out.println("referencing to: " + refClass.getName());
>
> // Get nodeEntities from relationNodeEntity
> ReportQuery reportQuery = new ReportQuery();
> reportQuery.setShouldReturnWithoutReportQueryResult(true);
> reportQuery.setReferenceClass(RelationNodeEntity.class);
> reportQuery.addAttribute(RelationNodeEntity.FIELD_NODE,
> nodeExpression, refClass);
> reportQuery.setSelectionCriteria(targetExpression);
>
>
> Whatever I write in the refClass (be it B or the subclass C or D), the
> query does not recognize the properties for class C nor D. How do I
> instruct the expression that the "join" does not point to the superclass B
> only, but also to C or D. I assumed that the refClass class would cast the
> B class to C or D, but with no success.
>
> My question, is it actually possible to make such a cast within the
> expression? When yes, how?
>
> Thank you,
> Jan De Cooman
>
>
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence
--
View this message in context: http://www.nabble.com/Expression%2C-joins-and-inheritance-tp22804915p22804953.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.