OpenJPA
  1. OpenJPA
  2. OPENJPA-478

Contradictory text in manual section 10.2.6. JPQL GROUP BY, HAVING

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.2, 2.1.0
    • Fix Version/s: 2.2.0
    • Component/s: docs
    • Labels:
      None
    • Environment:
      linux, firefox, etc..

      Description

      In section 10.2.6. JPQL GROUP BY, HAVING (http://openjpa.apache.org/docs/latest/manual/jpa_langref.html#jpa_langref_group) the last paragraph seems contradictory:

      """
      If there is no GROUP BY clause and the HAVING clause is used, the result is treated as a single group, and the select list can only consist of aggregate functions. When a query declares a HAVING clause, it must always also declare a GROUP BY clause.
      """

      The first sentences seems to imply that a query may incorporate a HAVING clause without a GROUP BY clause, but the second sentence indicates otherwise.

      Looking at section 10.2.12 JPQL BNF (http://openjpa.apache.org/docs/latest/manual/jpa_langref.html#jpa_langref_bnf), it seems as though the BNF contradicts the last sentence:

      """
      select_statement ::= select_clause from_clause [where_clause] [groupby_clause] [having_clause] [orderby_clause]
      """

      otherwise the BNF would be something like this:

      select_statement ::= select_clause from_clause [where_clause] [groupby_clause [having_clause]] [orderby_clause]

        Activity

        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.
        Hide
        Milosz Tylenda added a comment -

        OpenJPA supports HAVING without GROUP BY and assumes the database also allows such a construct. The manual is updated.

        Show
        Milosz Tylenda added a comment - OpenJPA supports HAVING without GROUP BY and assumes the database also allows such a construct. The manual is updated.
        Hide
        Milosz Tylenda added a comment -

        The JPA spec says:

        "If there is no GROUP BY clause and the HAVING clause is used, the result is treated as a single group,
        and the select list can only consist of aggregate functions. The use of HAVING in the absence of
        GROUP BY is not required to be supported by an implementation of this specification. Portable appli-
        cations should not rely on HAVING without the use of GROUP BY."

        If OpenJPA does not allow HAVING without GROUP BY, the paragraph in question could be changed to something like:

        "OpenJPA requires that if a query declares a HAVING clause, it must also declare a GROUP BY clause."

        Show
        Milosz Tylenda added a comment - The JPA spec says: "If there is no GROUP BY clause and the HAVING clause is used, the result is treated as a single group, and the select list can only consist of aggregate functions. The use of HAVING in the absence of GROUP BY is not required to be supported by an implementation of this specification. Portable appli- cations should not rely on HAVING without the use of GROUP BY." If OpenJPA does not allow HAVING without GROUP BY, the paragraph in question could be changed to something like: "OpenJPA requires that if a query declares a HAVING clause, it must also declare a GROUP BY clause."

          People

          • Assignee:
            Milosz Tylenda
            Reporter:
            Andy Schlaikjer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development