[ 
https://issues.apache.org/jira/browse/OPENJPA-1654?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Richard Zowalla resolved OPENJPA-1654.
--------------------------------------
    Resolution: Fixed

Already fixed on master: in_expression accepts scalar_function() on the left 
side (JPQL.jjt:870), and that rule reaches substring() through 
functions_returning_strings (JPQL.jjt:1344-1346); this came with d49fdb1ea 
(2009, trunk). Closing.

> Details of an ArgumentException if SUBSTRING() IN (...) is used
> ---------------------------------------------------------------
>
>                 Key: OPENJPA-1654
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1654
>             Project: OpenJPA
>          Issue Type: Improvement
>    Affects Versions: 1.2.2
>         Environment: IBM WebSphere 7.0.0.9 on Windows XP uses OpenJPA 1.2.3 
> in com.ibm.ws.jpa.jar
>            Reporter: Hannes Reisinger
>            Priority: Minor
>              Labels: ArgumentException, IN, SUBSTRING
>
> Everything works fine with the following two statements
> SQL: select * from table where substr(field,2,1)='6';
> JPA: SELECT o FROM Table o WHERE SUBSTRING(o.field,2,1)='6'
> but not with these
> SQL: select * from table where substr(field,2,1) in ('6','7');
> JPA: SELECT o FROM Table o WHERE SUBSTRING(o.field,2,1) IN ('6','7')
> SQL works as expected but JPA throws an exception
> org.apache.openjpa.persistence.ArgumentException "SUBSTRING ( o . field , 2 , 
> 1 ) IN" gefunden, erwartet wurde jedoch ["(", ")", "*", "+", ",", "-", ".", 
> "/", ":", "<", "<=", "<>", "=", ">", ">=", "?", "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", <BOOLEAN_LITERAL>, 
> <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL>].
> ejb-3_0-fr-spec-persistence.pdf "4.6.8 In Expressions" tells us
> in_expression ::= state_field_path_expression [NOT] IN ( in_item {, in_item}* 
> | subquery)
> "state_field_path_expression" is defined at "4.4.4 Path Expressions".
> As far as I understand, the result of SUBSTRING() is maybe not a 
> "state_field_path_expression" and therefore the exception is not a bug.
> But the error message could be improved. Because it tells us that IN is 
> allowed in this case - see the list of allowed terms at the ArgumentException 
> above.
> I would like to send a Query like "SELECT o FROM Table o WHERE 
> SUBSTRING(o.field,2,1) IN ('6','7')" but if this is not allowed I would like 
> to read an error message which guides me to the right direction.
> Thanks, Hannes



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to