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

FetchGroup is not returning lazy fields.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.2, 2.2.1.1, 2.2.3, 2.3.0, 2.4.0
    • Fix Version/s: 2.1.2, 2.2.2, 2.2.1.1, 2.4.0
    • Component/s: kernel
    • Labels:
      None

      Description

      I have found an issue with FetchGroups not returning 'lazy' fields. To describe, take this entity:

      @Entity
      @FetchGroup(name = "HardwareSimple", attributes =

      { @FetchAttribute(name = "status"), @FetchAttribute(name = "statusActive") }

      )
      public class HardwareStatus implements Serializable {

      @Id
      private String status;
      private String statusActive;
      private String condition;
      private int connection;
      ...............

      With this Entity, take the following scenario:

      OpenJPAEntityManager openJpaEm = OpenJPAPersistence.cast(em);
      openJpaEm.getFetchPlan().resetFetchGroups().removeFetchGroup("default").addFetchGroups("HardwareSimple");

      HardwareStatus h1 = em.find(HardwareStatus.class, "Lost");
      //h1.status contains "Lost" in the db.
      assertEquals("Lost",h1.getStatus()); //this assert passes
      //h1.connection contains '2' in the db.
      assertEquals(2, h1.getConnection()); //this assert fails, 0 is returned by the getter.
      //h1.condition contains "Used" in the db.
      assertEquals("Used", h1.getCondition()); //this assert fails, null is returned by the getter.

      The latter two h1.get* do not return the correct values. These fields are 'lazy' (i.e. not part of the FetchGroup) but should be fetched when requested. See the attached test for full details.

      Thanks,

      Heath

        Activity

        Hide
        curtisr7 Rick Curtis added a comment -

        Attaching a patch that fixes the reported problem. I'm not entirely happy with the change yet, but it is in the right area. I'll try to take a closer look at this one again next week.

        Show
        curtisr7 Rick Curtis added a comment - Attaching a patch that fixes the reported problem. I'm not entirely happy with the change yet, but it is in the right area. I'll try to take a closer look at this one again next week.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1655218 from Heath Thomann in branch 'openjpa/branches/2.1.x'
        [ https://svn.apache.org/r1655218 ]

        OPENJPA-2536: FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.1.x.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1655218 from Heath Thomann in branch 'openjpa/branches/2.1.x' [ https://svn.apache.org/r1655218 ] OPENJPA-2536 : FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.1.x.
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        OPENJPA-2536: FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.2.1.x.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1655220 from Heath Thomann in branch 'openjpa/branches/2.2.1.x' [ https://svn.apache.org/r1655220 ] OPENJPA-2536 : FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.2.1.x.
        Hide
        jira-bot ASF subversion and git services added a comment -

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

        OPENJPA-2536: FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.2.x.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1655221 from Heath Thomann in branch 'openjpa/branches/2.2.x' [ https://svn.apache.org/r1655221 ] OPENJPA-2536 : FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to 2.2.x.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 1655360 from Heath Thomann in branch 'openjpa/trunk'
        [ https://svn.apache.org/r1655360 ]

        OPENJPA-2536: FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to trunk.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 1655360 from Heath Thomann in branch 'openjpa/trunk' [ https://svn.apache.org/r1655360 ] OPENJPA-2536 : FetchGroup is not returning lazy fields. Applied Rick Curtis' fix to trunk.

          People

          • Assignee:
            curtisr7 Rick Curtis
            Reporter:
            jpaheath Heath Thomann
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development