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

JPQL constructor query close the <SELECT DISTINCT> feature?

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0.0
    • Fix Version/s: 1.0.2, 1.1.0
    • Component/s: kernel
    • Labels:
      None

      Description

      DISTINCT keyword,It can be supported in the simple query and subquery,but use constructor query,example:select distinct new org.apache.A(a.id...),the distinct keyword is ignored .
      I fixed as so:
      java file:org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder
      private Expression evalSelectClause(QueryExpressions exps) {
      if (exps.operation != QueryOperations.OP_SELECT)
      return null;

      JPQLNode selectNode = root();

      JPQLNode constructor = selectNode.findChildByID(JJTCONSTRUCTOR, true);
      if (constructor != null)

      { ... // add:now assign the distinct of the select clause JPQLNode selectClause = selectNode.findChildByID(JJTSELECTCLAUSE, false); if (selectClause != null && selectClause.hasChildID(JJTDISTINCT)) exps.distinct = exps.DISTINCT_TRUE | exps.DISTINCT_AUTO; else exps.distinct = exps.DISTINCT_FALSE; return assignProjections(right(constructor), exps); }

      else

      { .. }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              minewile minewile
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: