We're updating the issue view to help you get more done. 

Support defining lazy attribute fetch groups


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.:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 @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.





Steve Ebersole


Steve Ebersole

Fix versions