Uploaded image for project: 'Hibernate ORM'
  1. HHH-10267

Support defining lazy attribute fetch groups

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.1.0
    • Component/s: None
    • Labels:
      None
    • Last commented by a user?:
      true
    • Sprint:

      Description

      When using bytecode enhanced lazy loading, the current scheme is to fetch all lazy attributes when one is accessed. There are many times it would be great to define groupings of attributes to be fetched when one of the group is accessed.

      In a sense, the current scheme is a single "fetch group". This is about adding the ability for the user to explicitly control the definition of other groups.

      A single attribute could only belong to one fetch group.

      The annotation to control this is org.hibernate.annotations.LazyGroup, e.g.:

      @Entity
      public class Customer {
          @Id
          private Integer id;
          private String name;
          @Basic( fetch = FetchType.LAZY )
          private UUID accountsPayableXrefId;
          @Lob
          @Basic( fetch = FetchType.LAZY )
          @LazyGroup( "lobs" )
          private Blob image;
      
          ...
      }
      

      Both accountsPayableXrefId and image are lazy, but each is part of a different fetch group (accountsPayableXrefId is part of the default fetch group). Which means that accessing accountsPayableXrefId will not force the loading of image.

      By default all lazy singular attributes are part of a group named "DEFAULT" and all plural attributes are their own group.

      For many-to-one and one-to-one attributes, it is expected that they also be marked with @LazyToOne(LazyToOneOption.NO_PROXY), for now. The reason is legacy. We are discussing relaxing that requirement since I believe bytecode-enhancement + lazy to-ones always want NO_PROXY there.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                steve Steve Ebersole
                Reporter:
                steve Steve Ebersole
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 43.7h
                  43.7h