Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1923

Allow flexible (non-standard) syntax for collection-valued parameters in IN() expresseion of JPQL query

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 2.1.0, 2.2.0
    • query
    • None

    Description

      IN expression in JPQL query is defined in BNF as:

      in_expression ::=

      {state_field_path_expression | type_discriminator}

      [NOT] IN { ( in_item

      {, in_item}

      * ) | (subquery) | collection_valued_input_parameter }

      The parentheses are used for comma-separated in_term, but no parentheses around collection_valued_input_parameter. OpenJPA 2.0 adheres to this syntax and hence raises exception for
      String jpql = "select a from Address a where a.zip in ()";
      em.createQuery(jpql).setParameter(p, Array.asList(12345, 23456));

      java.lang.IllegalArgumentException:Invalid input parameter "p". A collection valued parameter syntax may incorrectly used in the query string. If the parameter is parenthesized, remove the parentheses and try again.

      However, earlier OpenJPA versions supported parentheses around the parameter.

      This issue will reinstate the behavior such that both queries
      "select a from Address a where a.zip in ()";
      "select a from Address a where a.zip in ";

      will be valid when parameter p is bound to a collection or list value.

      The unlikely case of binding a single value to "select a from Address a where a.zip in ()" will be disallowed.

      Attachments

        Activity

          People

            ppoddar@apache.org Pinaki Poddar
            ppoddar@apache.org Pinaki Poddar
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: