OpenJPA
  1. OpenJPA
  2. OPENJPA-1923

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1.0, 2.2.0
    • Component/s: query
    • Labels:
      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.

        Activity

        Hide
        Michael Dick added a comment -

        Resolving to prepare for 2.1.0 release.

        Show
        Michael Dick added a comment - Resolving to prepare for 2.1.0 release.
        Hide
        Albert Lee added a comment -

        Close issue in preparation for 2.2.0 release.

        Show
        Albert Lee added a comment - Close issue in preparation for 2.2.0 release.

          People

          • Assignee:
            Pinaki Poddar
            Reporter:
            Pinaki Poddar
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development