Uploaded image for project: '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

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0-M2
    • 2.0.0-M3
    • None
    • 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.*.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            fancy Catalina Wei
            fancy Catalina Wei
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment