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

LEFT JOIN FETCH not honored when data cache is enabled

    Details

      Description

      In a simple JPQL with left join fetch for a lazy loaded association specified and data cached enabled, first time the query executed, the lazy loaded association get loaded, returned and cached. Subsequent invocation of the same query does NOT "load" and return the association from the query invocation.

      I'll attach a test case to reproduce the problem.

      1. OPENJPA-2508.test.zip
        3 kB
        Albert Lee
      2. OPENJPA-2508.221x.patch
        30 kB
        Albert Lee
      3. qcsq.v2.patch
        5 kB
        Albert Lee

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1642995 from Jody Grassel in branch 'openjpa/branches/2.2.x'
        [ https://svn.apache.org/r1642995 ]

        OPENJPA-2508: Account for JOIN FETCH statements when loading from the Query Cache. - APICHK Fix

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1642995 from Jody Grassel in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1642995 ] OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache. - APICHK Fix
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1602060 from Heath Thomann in branch 'openjpa/branches/2.3.x'
        [ https://svn.apache.org/r1602060 ]

        OPENJPA-2508: Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.3.x Rick's trunk commit.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1602060 from Heath Thomann in branch 'openjpa/branches/2.3.x' [ https://svn.apache.org/r1602060 ] OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.3.x Rick's trunk commit.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1602052 from Heath Thomann in branch 'openjpa/branches/2.2.x'
        [ https://svn.apache.org/r1602052 ]

        OPENJPA-2508: Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.2.x Rick's trunk commit.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1602052 from Heath Thomann in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1602052 ] OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.2.x Rick's trunk commit.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1602032 from Heath Thomann in branch 'openjpa/branches/2.2.1.x'
        [ https://svn.apache.org/r1602032 ]

        OPENJPA-2508: Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.2.1.x Rick's trunk commit.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1602032 from Heath Thomann in branch 'openjpa/branches/2.2.1.x' [ https://svn.apache.org/r1602032 ] OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache. Back ported to 2.2.1.x Rick's trunk commit.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1600757 from Rick Curtis in branch 'openjpa/trunk'
        [ https://svn.apache.org/r1600757 ]

        OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1600757 from Rick Curtis in branch 'openjpa/trunk' [ https://svn.apache.org/r1600757 ] OPENJPA-2508 : Account for JOIN FETCH statements when loading from the Query Cache.
        Hide
        allee8285 Albert Lee added a comment -

        Revised (v2) patch by Rick C.

        I have tested it and passed the TestNPE2, JUnit and my application.

        Show
        allee8285 Albert Lee added a comment - Revised (v2) patch by Rick C. I have tested it and passed the TestNPE2, JUnit and my application.
        Hide
        curtisr7 Rick Curtis added a comment -

        I'd prefer to stay away from reflection. I banged something together quickly that seems to work, but there are a few unknowns with my approach.

        Show
        curtisr7 Rick Curtis added a comment - I'd prefer to stay away from reflection. I banged something together quickly that seems to work, but there are a few unknowns with my approach.
        Hide
        allee8285 Albert Lee added a comment -

        The test case call doQuery() twice, i.e. same call path. The first call executes the SQLs and fetches Dept and Employee from the db. Both dept and employee were cached. The second call the Employee was fetched from cache but the Employee.dept remains null even the SQL requests to load dept using "join fetch dept".

        The attached test will pass (Employee.dept is loaded; not null) if either:
        1) the Employee.dept is marked FetchType.EAGER, or
        2) TestNPE2.doquery().... em.detach(emp) is removed.

        Show
        allee8285 Albert Lee added a comment - The test case call doQuery() twice, i.e. same call path. The first call executes the SQLs and fetches Dept and Employee from the db. Both dept and employee were cached. The second call the Employee was fetched from cache but the Employee.dept remains null even the SQL requests to load dept using "join fetch dept". The attached test will pass (Employee.dept is loaded; not null) if either: 1) the Employee.dept is marked FetchType.EAGER, or 2) TestNPE2.doquery().... em.detach(emp) is removed.

          People

          • Assignee:
            jpaheath Heath Thomann
            Reporter:
            allee8285 Albert Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development