Support defining lazy attribute fetch groups

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

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.

Activity

Show:

Steve Ebersole November 11, 2015 at 4:49 AM

Notes to self...

  • Many places in the code base have a concept of "lazyPropertiesAreUnfetched". The simple boolean worked previously because of the fact that there was just one fetch group. As we transition to multiple fetch groups this needs to change to become the name of all fetched fetch-groups (all unfetched groups works too, but fetched groups is better).

  • org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromDatastore (as part of the org.hibernate.bytecode.instrumentation.spi.LazyPropertyInitializer#initializeLazyProperty call chain) needs to be re-worked to understand fetch groups. Which means org.hibernate.persister.entity.AbstractEntityPersister#getSQLLazySelectString needs similar reworking

Fixed

Details

Assignee

Reporter

Time tracking

43.7h logged

Fix versions

Priority

Created November 11, 2015 at 2:55 AM
Updated July 12, 2016 at 8:36 PM
Resolved November 16, 2015 at 9:25 PM
Loading...