OpenJPA
  1. OpenJPA
  2. OPENJPA-920

LIKE does not accept expression as second parameter

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JDK 1.6

      Description

      I have simple data object :

      @Id
      String Id ;

      @Basic
      @Column(name="my_value", nullable=false, length=36)
      String value ;

      OpenJPA give my the following exception when execute the query:

      SELECT t from MySimpleObject t WHERE ?1 like concat(t.value,'%')

      Exception in thread "main" <openjpa-1.2.0-rexported nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Encountered "? 1 like concat" at character 38, but expected: ["(", "*", "+", "-", "/", ":", "<", "<=", "<>", "=", ">", ">=", "?", "BETWEEN", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "EXISTS", "IS", "LIKE", "MEMBER", "NOT", <BOOLEAN_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL>].
      at org.apache.openjpa.kernel.jpql.JPQL.generateParseException(JPQL.java:9501)
      at org.apache.openjpa.kernel.jpql.JPQL.jj_consume_token(JPQL.java:9378)
      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)
      at org.apache.openjpa.kernel.jpql.JPQL.conditional_expression(JPQL.java:1753)
      at org.apache.openjpa.kernel.jpql.JPQL.where_clause(JPQL.java:1556)
      at org.apache.openjpa.kernel.jpql.JPQL.select_statement(JPQL.java:91)
      at org.apache.openjpa.kernel.jpql.JPQL.parseQuery(JPQL.java:63)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1740)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1727)
      at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:48)
      at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:149)
      at org.apache.openjpa.datacache.QueryCacheStoreQuery.newCompilation(QueryCacheStoreQuery.java:241)
      at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:657)
      at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639)
      at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
      at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
      at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1492)
      at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:123)
      at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:243)
      at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:293)
      at Tester.simpleJpql(Tester.java:87)
      at Tester.main(Tester.java:180)

        Issue Links

          Activity

          Show
          Julien Kronegg added a comment - Reference to JPA specifications: JPA 1: http://cds-esd.sun.com/ESD24/JSCDL/ejb/3.0-fr/ejb-3_0-fr-spec-persistence.pdf (pages 92-93) JPA 2: http://cds-esd.sun.com/ESD7/JSCDL/persistence/3.0-pfd/persistence-3_0-pfd-spec.pdf (pages 138-139)
          Hide
          Georgi Naplatanov added a comment -

          It's not according specification. For this type of queries can be used LOCATE function.

          Show
          Georgi Naplatanov added a comment - It's not according specification. For this type of queries can be used LOCATE function.
          Hide
          Milosz Tylenda added a comment -

          You can make this bug invalid or, if you think this lacking functionality is important, you can change the issue type from Bug to Wish, for example.

          Show
          Milosz Tylenda added a comment - You can make this bug invalid or, if you think this lacking functionality is important, you can change the issue type from Bug to Wish, for example.
          Hide
          Georgi Naplatanov added a comment -

          Hello, Milosz.

          In case pattern_value do not accepts string_expression values I should make this bug invalid, right ?

          Show
          Georgi Naplatanov added a comment - Hello, Milosz. In case pattern_value do not accepts string_expression values I should make this bug invalid, right ?
          Hide
          Milosz Tylenda added a comment -

          Georgi, I believe that this is more of an enhancement request than a bug. The JPA 1 & 2 specs say:

          string_expression [NOT] LIKE pattern_value [ESCAPE escape_character]

          The pattern_value is a string literal or a string-valued input parameter [...]

          Show
          Milosz Tylenda added a comment - Georgi, I believe that this is more of an enhancement request than a bug. The JPA 1 & 2 specs say: string_expression [NOT] LIKE pattern_value [ESCAPE escape_character] The pattern_value is a string literal or a string-valued input parameter [...]

            People

            • Assignee:
              Unassigned
              Reporter:
              Georgi Naplatanov
            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development