[ https://issues.apache.org/jira/browse/OPENJPA-2572?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Heath Thomann closed OPENJPA-2572. ---------------------------------- Resolution: Not a Problem > Parentheses before an IN operator causes a parser exception. > ------------------------------------------------------------ > > Key: OPENJPA-2572 > URL: https://issues.apache.org/jira/browse/OPENJPA-2572 > Project: OpenJPA > Issue Type: Bug > Components: sql > Affects Versions: 2.2.3, 2.4.0 > Reporter: Heath Thomann > Priority: Critical > > I have recreated a simple version of a more complex query which is not > working. Take these two queries which work fine and as expected: > em.createQuery("select m from MyEntity2 m WHERE (m.id = 1)"); > em.createQuery("select m from MyEntity2 m WHERE m.id IN (1,2,5)"); > Now take this query and note the parentheses around m.id: > em.createQuery("select m from MyEntity2 m WHERE (m.id) IN (1,2,5)"); > This yields the following exception: > Caused by: <openjpa-2.2.3-SNAPSHOT-r422266:1655221M nonfatal user error> > org.apache.openjpa.persistence.ArgumentException: Encountered "m . id ) IN" > at character 34, 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", "TYPE", "UPDATE", "UPPER", "WHERE", <DATE_LITERAL>, > <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL2>, > <STRING_LITERAL>, <TIMESTAMP_LITERAL>, <TIME_LITERAL>]. > at > org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:13180) > at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:13054) > at > org.apache.openjpa.kernel.jpql.JPQL.conditional_primary(JPQL.java:1980) > ........ > Looks like something in our parser doesn't expect this. > Oh, BTW, the answer is not to simply remove the parentheses......ultimately > what we want to do is something more like the following (this works when I > execute from my Oracle SQL editor): > SELECT * FROM MyEntity2 t0 WHERE (t0.id, t0.num) IN (SELECT t1.id, t1.num > FROM MyEntity2 t1 GROUP BY t1.id, t1.num); > I.e. we need the parentheses. > Thanks, > Heath Thomann -- This message was sent by Atlassian JIRA (v6.3.4#6332)