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

        Attachments

          Activity

            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: