OpenJPA
  1. OpenJPA
  2. OPENJPA-731

Bug on FetchType.EAGER when QuerySQLCache is turned on

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0, 1.2.1
    • Fix Version/s: 1.2.1, 1.3.0
    • Component/s: None
    • Labels:
      None

      Description

      This JIRA is open on behalf of Enrico:

      OpenJPA 1.2.0 Bug on FetchType.EAGER
      Friday, September 19, 2008 12:49 AM
      From: "egoosen" <egoosen2@metropolitan.co.za>
      Add sender to Contacts
      To: users@openjpa.apache.org

      I'm experiencing a strange bug in 1.2.0, on an eager loaded one to many
      relationship.
      The first time I run the code, openJPA retrieves the parent entity and eager
      fetches the CORRECT child entities.
      The second time around, it fetches the parent entity and fetches the
      INCORRECT child entities (specifically, it fetches the child entities of the
      parent entity in the previous query).

      Here's the SQL to illustrate:
      First run:
      SELECT t0.AMDCTL_ID, t0.VRS_NBR, t0.AMDSEQ_CDE, t0.DPLORD_NBR, t0.FND_CDE,
      t0.RSL_DTE FROM EBSTATUS.TBL_AMDCTL t0 WHERE t0.FND_CDE = ?
      [params=(String) 0000001]
      SELECT t0.AMDCTL_ID, t1.AMDDES_ID, t1.VRS_NBR, t1.AMD_DES, t1.AMDCTL_ID,
      t1.EFC_DTE FROM EBSTATUS.TBL_AMDCTL t0 INNER JOIN EBSTATUS.TBL_AMDDES t1 ON
      t0.AMDCTL_ID = t1.AMDCTL_ID WHERE t0.FND_CDE = ? ORDER BY t0.AMDCTL_ID ASC
      [params=(String) 0000001]

      Second run:
      SELECT t0.AMDCTL_ID, t0.VRS_NBR, t0.AMDSEQ_CDE, t0.DPLORD_NBR, t0.FND_CDE,
      t0.RSL_DTE FROM EBSTATUS.TBL_AMDCTL t0 WHERE t0.FND_CDE = ?
      [params=(String) 0001001]
      SELECT t0.AMDCTL_ID, t1.AMDDES_ID, t1.VRS_NBR, t1.AMD_DES, t1.AMDCTL_ID,
      t1.EFC_DTE FROM EBSTATUS.TBL_AMDCTL t0 INNER JOIN EBSTATUS.TBL_AMDDES t1 ON
      t0.AMDCTL_ID = t1.AMDCTL_ID WHERE t0.FND_CDE = ? ORDER BY t0.AMDCTL_ID ASC
      [params=(String) 0000001]

      Somehow its caching the second query, even though I've turned off the
      DataCache and QueryCache.

      I've had to revert back to OpenJPA 1.1.0.

      Here's my mappings:
      TblAmdctl.java
      @OneToMany(mappedBy="tblAmdctl",fetch = FetchType.EAGER,cascade =

      { CascadeType.PERSIST,CascadeType.MERGE}

      )
      private Collection<TblAmddes> tblAmddess = new ArrayList<TblAmddes>();

      TblAmddes.java
      @ManyToOne(fetch = FetchType.LAZY,cascade =

      { CascadeType.PERSIST,CascadeType.MERGE }

      )
      @JoinColumns(

      {@JoinColumn(name = "AMDCTL_ID",referencedColumnName="AMDCTL_ID")}

      )
      @ForeignKey
      private TblAmdctl tblAmdctl;

      1. testcase.jar
        2 kB
        Fay Wang
      2. openjpa-731.txt
        13 kB
        Fay Wang

        Activity

        Fay Wang created issue -
        Hide
        Fay Wang added a comment -

        Hi Enrico, attached is the test case based on your report. However, this test case works fine. Could you attach your entity classes (TblAmdctl.java, and TblAmddes.java)? Also, do you use find operation or Query to get the parent entity? Can you provide a code snippet for your operation? Thanks!

        Show
        Fay Wang added a comment - Hi Enrico, attached is the test case based on your report. However, this test case works fine. Could you attach your entity classes (TblAmdctl.java, and TblAmddes.java)? Also, do you use find operation or Query to get the parent entity? Can you provide a code snippet for your operation? Thanks!
        Fay Wang made changes -
        Field Original Value New Value
        Attachment testcase.jar [ 12390524 ]
        Fay Wang made changes -
        Attachment openjpa-731.txt [ 12390975 ]
        Hide
        Catalina Wei added a comment -

        Fix checked in under r699156

        Show
        Catalina Wei added a comment - Fix checked in under r699156
        Catalina Wei made changes -
        Fix Version/s 1.3.0 [ 12313326 ]
        Assignee Fay Wang [ faywang ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Michael Dick made changes -
        Affects Version/s 1.2.0 [ 12313102 ]
        Affects Version/s 1.2.1 [ 12313328 ]
        Hide
        Michael Dick added a comment -

        Merged change to 1.2.1.

        Show
        Michael Dick added a comment - Merged change to 1.2.1.
        Michael Dick made changes -
        Fix Version/s 1.2.1 [ 12313328 ]
        Donald Woods made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        6d 9h 45m 1 Catalina Wei 26/Sep/08 03:09
        Resolved Resolved Closed Closed
        529d 15h 23m 1 Donald Woods 09/Mar/10 18:32

          People

          • Assignee:
            Fay Wang
            Reporter:
            Fay Wang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development