openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Dirichs (JIRA)" <>
Subject [jira] Updated: (OPENJPA-1719) Prepared SQL cache ordering problem with subqueries.
Date Sun, 25 Jul 2010 23:19:49 GMT


Martin Dirichs updated OPENJPA-1719:

    Attachment: OpenJPA-trunk_OJ1719.testcase.patch

You find a test case attached in file OpenJPA-trunk_OJ1719.testcase.patch.

Yes, with lines 172-174 simplified the code should work correctly.

Perhaps you also find value in my objections to code safety and code duplication stated above.

> Prepared SQL cache ordering problem with subqueries. 
> -----------------------------------------------------
>                 Key: OPENJPA-1719
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Michael Dick
>            Assignee: Catalina Wei
>             Fix For: 2.0.1, 2.1.0
>         Attachments: OpenJPA-trunk_OJ1719.testcase.patch, sql-cache-subqordering.diff.txt
> I've found what appears to be an ordering issue with subqueries and the prepared SQL
cache. The attached patch shows where I think the problem lies and adds a test method that
shows the problem. 
> To summarize: When the prepared SQL cache is enabled we reorder the parameter values
provided by the user. If a query contains named parameters and a subquery which also contains
named parameters the placement of the subquery becomes important. 
> The following query will work : 
> SELECT p FROM Person p WHERE IN (SELECT FROM Person p1 WHERE p1.lastUpdated
>= :date ) AND = :name
> But this one fails with a SQLDataException.
> SELECT p FROM Person p WHERE = :name AND IN (SELECT FROM Person p1
WHERE p1.lastUpdated >= :date )
> Assuming that the query is executed something like this : 
>         Query query = em.createQuery(query);
>         query.setParameter("name", "mike");
>         query.setParameter("date", new java.sql.Date(1005397));  

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message