[
https://issues.apache.org/jira/browse/JDO-568?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562896#action_12562896
]
Andy Jefferson commented on JDO-568:
------------------------------------
"CorrelatedSubqueriesWithParameters" has a query of
Query sub = pm.newQuery(Employee.class);
sub.setResult("avg(this.weeklyhours)");
sub.setFilter("this.manager == :manager");
Query apiQuery = pm.newQuery(Employee.class);
apiQuery.setFilter("this.weeklyhours> averageWeeklyhours");
apiQuery.addSubquery(sub, "double averageWeeklyhours",
"this.department.employees", "this.manager");
which in single-string JDOQL is
SELECT FROM Employee WHERE this.weeklyhours >
(SELECT AVG(e.weeklyhours) FROM this.department.employees e
WHERE e.manager == this.manager)
JPOX is translating this into
SELECT THIS.DISCRIMINATOR,THIS.DATASTORE_IDENTITY, ...
FROM datastoreidentity0.PERSONS THIS
WHERE (THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.Employee'>
OR THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.PartTimeEmployee'>
OR THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.FullTimeEmployee'>)
AND THIS.WEEKLYHOURS > (
SELECT AVG(SUB.WEEKLYHOURS) FROM datastoreidentity0.PERSONS SUB
INNER JOIN datastoreidentity0.DEPARTMENTS T1 ON T1.DATASTORE_IDENTITY =
SUB.DEPARTMENT
WHERE (SUB.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.Employee'>
OR SUB.DISCRIMINATOR =
<'org.apache.jdo.tck.pc.company.PartTimeEmployee'>
OR SUB.DISCRIMINATOR =
<'org.apache.jdo.tck.pc.company.FullTimeEmployee'>)
AND T1.DATASTORE_IDENTITY = THIS.DEPARTMENT
AND THIS.MANAGER = SUB.MANAGER)
which is correct in my understanding of the intention of correlated subqueries
and their parameters.
The JPOX query returns
[PartTimeEmployee(9), FullTimeEmployee(6), FullTimeEmployee(2)]
whereas the query is expecting
[FullTimeEmployee(2), FullTimeEmployee(6)]
Anyone see the error in the query ? or the expectations?
The previous test "CorrelatedSubqueries" has the same query without the manager
parameter and is generating the SQL
SELECT THIS.DISCRIMINATOR,THIS.DATASTORE_IDENTITY, ...
FROM datastoreidentity0.PERSONS THIS
WHERE (THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.Employee'>
OR THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.PartTimeEmployee'>
OR THIS.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.FullTimeEmployee'>)
AND THIS.WEEKLYHOURS > (
SELECT AVG(SUB.WEEKLYHOURS) FROM datastoreidentity0.PERSONS SUB
INNER JOIN datastoreidentity0.DEPARTMENTS T1 ON T1.DATASTORE_IDENTITY =
SUB.DEPARTMENT
WHERE (SUB.DISCRIMINATOR = <'org.apache.jdo.tck.pc.company.Employee'>
OR SUB.DISCRIMINATOR =
<'org.apache.jdo.tck.pc.company.PartTimeEmployee'>
OR SUB.DISCRIMINATOR =
<'org.apache.jdo.tck.pc.company.FullTimeEmployee'>)
AND T1.DATASTORE_IDENTITY = THIS.DEPARTMENT)
and gives the expected result (with JPOX SVN)
> Add subquery support to JPOX
> ----------------------------
>
> Key: JDO-568
> URL: https://issues.apache.org/jira/browse/JDO-568
> Project: JDO
> Issue Type: Task
> Components: tck2, tck2-legacy
> Affects Versions: JDO 2 maintenance release 1
> Reporter: Michael Bouschen
> Assignee: Andy Jefferson
> Fix For: JDO 2 maintenance release 1
>
> Attachments: JDO-568.patch
>
>
> The subquery test cases currently fail, because JPOX does not yet support
> subqueries:
> [java] RUN CorrelatedSubqueries.testPositive ERROR
> [java] RUN CorrelatedSubqueriesWithParameters.testPositive ERROR
> [java] RUN MultipleCallsReplaceSubquery.testPositive ERROR
> [java] RUN NonCorrelatedSubqueries.testPositive ERROR
> [java] RUN NullCandidateCollectionExpression.testPositive ERROR
> [java] RUN NullSubqueryParameter.testPositive ERROR
> [java] RUN UnmodifiedSubqueryInstance.testPositive ERROR
> Here is the corresponding JPOX JIRA:
> http://www.jpox.org/servlet/jira/browse/CORE-3207.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.