Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 35757 invoked from network); 11 Jul 2010 19:58:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Jul 2010 19:58:15 -0000 Received: (qmail 82189 invoked by uid 500); 11 Jul 2010 19:58:14 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 82138 invoked by uid 500); 11 Jul 2010 19:58:14 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 82129 invoked by uid 99); 11 Jul 2010 19:58:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 19:58:13 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 19:58:11 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o6BJvn3L029886 for ; Sun, 11 Jul 2010 19:57:50 GMT Message-ID: <15527985.316571278878269411.JavaMail.jira@thor> Date: Sun, 11 Jul 2010 15:57:49 -0400 (EDT) From: "Catalina Wei (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Assigned: (OPENJPA-1719) Prepared SQL cache ordering problem with subqueries. In-Reply-To: <8415550.240151278515030388.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/OPENJPA-1719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Catalina Wei reassigned OPENJPA-1719: ------------------------------------- Assignee: Catalina Wei > Prepared SQL cache ordering problem with subqueries. > ----------------------------------------------------- > > Key: OPENJPA-1719 > URL: https://issues.apache.org/jira/browse/OPENJPA-1719 > 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: 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 p.id IN (SELECT p1.id FROM Person p1 WHERE p1.lastUpdated >= :date ) AND p.name = :name > But this one fails with a SQLDataException. > SELECT p FROM Person p WHERE p.name = :name AND p.id IN (SELECT p1.id 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.