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