OpenJPA
  1. OpenJPA
  2. OPENJPA-1283

Incorrect SQL for JPQL query selecting Map value from an elementCollection of a Map and the map the value is an embeddable

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M3
    • Component/s: None
    • Labels:
      None

      Description

      SELECT VALUE(f) FROM Policy p, IN (p.funds) f WHERE f.fundName = :fName and p.annuityHolderId = :holderId

      Where Policy has an ElementCollection as a Map:

      @ElementCollection(targetClass = Fund.class, fetch=FetchType.EAGER)
      @CollectionTable(name="POLICY_FUNDS",joinColumns=

      {@JoinColumn(name="FK_POLICY_ID")}

      )
      @MapKeyColumn(name = "FUND_ID")
      public Map<Integer, IFund> getFunds()

      { return Funds; }

      The generated SQL was incorrect:

      SELECT t2.id FROM INSPOLICY t0
      INNER JOIN POLICY_FUNDS t1 ON t0.id = t1.FK_POLICY_ID,
      INSPOLICY t2
      WHERE (t1.fundName = ? AND t0.FK_ANNUITY_HOLDER_ID = ?)

      The correct SQL should projecting out t1.*.

        Activity

        Catalina Wei created issue -
        Hide
        Catalina Wei added a comment -

        Fix checked in trunk svn r810744

        Show
        Catalina Wei added a comment - Fix checked in trunk svn r810744
        Catalina Wei made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Donald Woods made changes -
        Fix Version/s 2.0.0-M3 [ 12314148 ]
        Fix Version/s 2.0.0 [ 12314019 ]
        Affects Version/s 2.0.0-M2 [ 12313483 ]
        Affects Version/s 2.0.0 [ 12314019 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Catalina Wei
            Reporter:
            Catalina Wei
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development