Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 10866 invoked from network); 28 Sep 2010 23:44:54 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Sep 2010 23:44:54 -0000 Received: (qmail 18270 invoked by uid 500); 28 Sep 2010 23:44:54 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 18210 invoked by uid 500); 28 Sep 2010 23:44:53 -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 18202 invoked by uid 99); 28 Sep 2010 23:44:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Sep 2010 23:44:53 +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; Tue, 28 Sep 2010 23:44:53 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8SNiW4H007054 for ; Tue, 28 Sep 2010 23:44:32 GMT Message-ID: <2574391.454181285717472530.JavaMail.jira@thor> Date: Tue, 28 Sep 2010 19:44:32 -0400 (EDT) From: "Catalina Wei (JIRA)" To: dev@openjpa.apache.org Subject: [jira] Updated: (OPENJPA-1814) JPQL fails with Group By and Having aggregate_expression IN (subquery) In-Reply-To: <33423435.388621285352192362.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OPENJPA-1814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Catalina Wei updated OPENJPA-1814: ---------------------------------- Assignee: Catalina Wei (was: Fay Wang) Fix Version/s: 2.1.0 Environment: Fix committed to trunk at revision #1002419. OPENJPA-1814-2.patch committed to trunk at revision #1002419. > JPQL fails with Group By and Having aggregate_expression IN (subquery) > ---------------------------------------------------------------------- > > Key: OPENJPA-1814 > URL: https://issues.apache.org/jira/browse/OPENJPA-1814 > Project: OpenJPA > Issue Type: Bug > Components: kernel > Affects Versions: 2.1.0 > Environment: Fix committed to trunk at revision #1002419. > Reporter: Fay Wang > Assignee: Catalina Wei > Fix For: 2.1.0 > > Attachments: OPENJPA-1814-1.patch, OPENJPA-1814-2.patch, OPENJPA-1814.patch > > > The following JPQL fail: > String jpql = "SELECT a.uuid from EntityA a WHERE a.name = 'test' " + > "GROUP BY a.date1, a.uuid " + > (1) "HAVING MAX(a.date1) IN (SELECT MAX(a1.date2) from EntityA a1 WHERE a1.name = 'test') "; > (2) "HAVING MAX(a.date1) = (SELECT MAX(a1.date2) from EntityA a1 WHERE a1.name = 'test') "; > org.apache.openjpa.persistence.ArgumentException: Encountered "MAX ( a .date1) IN" at character 168, but expected: ["(", ")", "*", "+", "-", ".", "/", ":", "<", "<=", "<>", "=", ">", ">=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH", "BY", "CONCAT","COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INNER", "IS", "JOIN", "LEADING", "LEFT","LENGTH", "LIKE", "LOCATE", "LOWER", "MAX", "MEMBER", "MIN", "MOD","NEW", "NOT", "NULL", "OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", > "SET", "SIZE", "SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM","UPDATE", "UPPER", "WHERE", , ,, , ]. > at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9566) > at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9443) > at org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1947) > at org.apache.openjpa.kernel.jpql.JPQL.conditional_factor(JPQL.java:1925) > at org.apache.openjpa.kernel.jpql.JPQL.conditional_term(JPQL.java:1791) > The fix involves two changes: > (1) jjt grammar change > (2) OpenJPA performs a preliminary validation to ensure the expression in the having clause is included in the group-by list. However, this validation checking should be done only on the LHS of the having clause (see expr1 below), not on the RHS (see expr2 below). For example: > Having expr1 = expr2 > Only expr1 should be in the group-by list > The current visitor pattern can not tell which node to visit without massive change. The alternative is to disable the checking by OpenJPA and let the backend to determine whether the generated SQL is valid or not. > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.