Hi Gordon,
thanks for the info.
Yes, I saw your checkin and started looking into adding support for
EJBQL queries with multiple expressions in the SELECT clause. The
example setup code helps (e.g. I was not aware of method
returnWithoutReportQueryResult).
However, I still have some questions and hope you can help:
(1) Both examples use a ReportQuery. The current EJBQL code creates an
ReadAllQuery if the SELECT clause uses an identification variable
"SELECT c FROM Customer c". In all other cases it creates a ReportQuery.
Is there any specific reason to create a ReadAllQuery (and not a
ReportQuery) for the above EJBQL? It would be easier if we could always
create a ReportQuery for an EJBQL SELECT query.
(2) What is the reference class in case of multiple expressions
selecting values from different classes? E.g.
SELECT c.name, o.totalPrice FROM Order o JOIN o.customer c
And what is it if one of the expression selects an association field?
SELECT o.customer, o.orderId, o.totalPrice FROM Order o
Regards Michael
> Hello Michael,
> I'm not sure how Tom generally organises these feature notifications but i have compeleted (and checked into CVS) the work required to return multiple return types in a single EJBQL query (ie Select o.customer, o.id, FROM Order o where o.customer.name='Somename')
>
> To support this type of selection a TopLink ReportQuery should be used. Each of the selection items (ie o.customer) can be added as an attribute. So as an example the setup code for the above EJBQL would be:
>
> ReportQuery reportQuery = new ReportQuery();
> reportQuery.returnWithoutReportQueryResult();
> reportQuery.setReferenceClass(Order.class);
> ExpressionBuilder orderBuilder = reportQuery.getExpressionBuilder();
> reportQuery.addAttribute("someString-a",empbuilder.get("customer"));
> reportQuery.addAttribute("someString-b",empbuilder.get("id"));
> reportQuery.setSelectionCriteria(empbuilder.get("customer").get("name").equal("Somename");
>
>
>
> Selecting a base object for a query like SELECT c FROM Customer c can be completed as follows:
>
> ReportQuery reportQuery = new ReportQuery();
> reportQuery.returnWithoutReportQueryResult();
> reportQuery.setReferenceClass(Customer.class);
> ExpressionBuilder customerBuilder = reportQuery.getExpressionBuilder();
> reportQuery.addAttribute("someString-a", empbuilder);
>
> This is not quite straight forward so if you have any questions please feel free to ask.
> --Gordon
> __
> Gordon Yorke
> Senior Software Engineer
> TopLink
> Oracle Canada
> <http://www.oracle.com/>
> Main: (613) 783-4585
> Email: gordon.yorke_at_oracle.com
>
>