Skip to main content

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

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

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



Back to the top