Class AbstractImmediateCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- java.lang.Object
-
- org.hibernate.sql.results.graph.internal.AbstractInitializer<Data>
-
- org.hibernate.sql.results.graph.collection.internal.AbstractCollectionInitializer<Data>
-
- org.hibernate.sql.results.graph.collection.internal.AbstractImmediateCollectionInitializer<Data>
-
- All Implemented Interfaces:
BiConsumer<Data,List<Object>>
,CollectionInitializer<Data>
,Initializer<Data>
,InitializerParent<Data>
- Direct Known Subclasses:
ArrayInitializer
,BagInitializer
,ListInitializer
,MapInitializer
,SetInitializer
public abstract class AbstractImmediateCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData> extends AbstractCollectionInitializer<Data> implements BiConsumer<Data,List<Object>>
Base support for CollectionInitializer implementations that represent an immediate initialization of some sort (join, select, batch, sub-select) for a persistent collection.- Implementation Note:
- Mainly an intention contract wrt the immediacy of the fetch.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData
-
Nested classes/interfaces inherited from class org.hibernate.sql.results.graph.collection.internal.AbstractCollectionInitializer
AbstractCollectionInitializer.CollectionInitializerData
-
Nested classes/interfaces inherited from interface org.hibernate.sql.results.graph.Initializer
Initializer.State
-
-
Field Summary
Fields Modifier and Type Field Description protected @Nullable DomainResultAssembler<?>
collectionValueKeyResultAssembler
refers to the rows entry in the collection.-
Fields inherited from class org.hibernate.sql.results.graph.collection.internal.AbstractCollectionInitializer
collectionAttributeMapping, collectionKeyResultAssembler, collectionPath, isResultInitializer, keyTypeForEqualsHashCode, owningEntityInitializer, parent
-
Fields inherited from class org.hibernate.sql.results.graph.internal.AbstractInitializer
initializerId
-
Fields inherited from interface org.hibernate.sql.results.graph.Initializer
EMPTY_ARRAY
-
-
Constructor Summary
Constructors Constructor Description AbstractImmediateCollectionInitializer(NavigablePath collectionPath, PluralAttributeMapping collectionAttributeMapping, InitializerParent<?> parent, LockMode lockMode, DomainResult<?> collectionKeyResult, DomainResult<?> collectionValueKeyResult, boolean isResultInitializer, AssemblerCreationState creationState)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
accept(Data data, List<Object> objects)
protected AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData
createInitializerData(RowProcessingState rowProcessingState)
protected void
forEachSubInitializer(BiConsumer<Initializer<?>,RowProcessingState> consumer, InitializerData data)
abstract DomainResultAssembler<?>
getElementAssembler()
abstract @Nullable DomainResultAssembler<?>
getIndexAssembler()
boolean
hasLazySubInitializers()
Indicates whether this initializer has sub-initializers which are lazy.void
initializeInstance(Data data)
Step 3 - Initialize the state of the instance resolved inInitializer.resolveInstance(Data)
from the current row values.void
initializeInstanceFromParent(Object parentInstance, Data data)
Step 3.1 - Initialize the state of the instance as extracted from the given parentInstance.protected void
initializeShallowCached(Data data)
protected abstract void
initializeSubInstancesFromParent(Data data)
protected abstract void
readCollectionRow(Data data, List<Object> loadingState)
void
resolveFromPreviousRow(Data data)
Step 1.2 - Special variant ofInitializer.resolveKey(InitializerData)
that allows the reuse of key value and instance value from the previous row.void
resolveInstance(Data data)
Step 2.1 - Using the key resolved inInitializer.resolveKey(Data)
, resolve the instance (of the thing initialized) to use for the current row.void
resolveInstance(Object instance, Data data)
Step 2.2 - Use the given instance as resolved instance for this initializer.protected abstract void
resolveInstanceSubInitializers(Data data)
void
resolveKey(Data data)
Step 1.1 - Resolve the key value for this initializer for the current row and then recurse to the sub-initializers.void
resolveState(Data data)
protected void
setMissing(Data data)
protected void
takeResponsibility(Data data)
-
Methods inherited from class org.hibernate.sql.results.graph.collection.internal.AbstractCollectionInitializer
getCollectionAttributeMapping, getCollectionInstance, getInitializedPart, getNavigablePath, getParent, isEager, isPartOfKey, isResultInitializer, resolveCollectionKey
-
Methods inherited from class org.hibernate.sql.results.graph.internal.AbstractInitializer
finishUpRow, getData, startLoading
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.function.BiConsumer
andThen
-
Methods inherited from interface org.hibernate.sql.results.graph.collection.CollectionInitializer
asCollectionInitializer, getCollectionInstance, getInitializingCollectionDescriptor, isCollectionInitializer
-
Methods inherited from interface org.hibernate.sql.results.graph.Initializer
asEmbeddableInitializer, asEntityInitializer, endLoading, endLoading, findOwningEntityInitializer, finishUpRow, finishUpRow, getData, getResolvedInstance, getResolvedInstance, initializeInstance, initializeInstanceFromParent, isEmbeddableInitializer, isEntityInitializer, isLazyCapable, resolveFromPreviousRow, resolveInstance, resolveInstance, resolveKey, resolveState, startLoading
-
-
-
-
Field Detail
-
collectionValueKeyResultAssembler
protected final @Nullable DomainResultAssembler<?> collectionValueKeyResultAssembler
refers to the rows entry in the collection. null indicates that the collection is empty
-
-
Constructor Detail
-
AbstractImmediateCollectionInitializer
public AbstractImmediateCollectionInitializer(NavigablePath collectionPath, PluralAttributeMapping collectionAttributeMapping, InitializerParent<?> parent, LockMode lockMode, DomainResult<?> collectionKeyResult, DomainResult<?> collectionValueKeyResult, boolean isResultInitializer, AssemblerCreationState creationState)
-
-
Method Detail
-
createInitializerData
protected AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData createInitializerData(RowProcessingState rowProcessingState)
- Overrides:
createInitializerData
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
forEachSubInitializer
protected void forEachSubInitializer(BiConsumer<Initializer<?>,RowProcessingState> consumer, InitializerData data)
- Overrides:
forEachSubInitializer
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveKey
public void resolveKey(Data data)
Description copied from interface:Initializer
Step 1.1 - Resolve the key value for this initializer for the current row and then recurse to the sub-initializers. After this point, the initializer knows whether further processing is necessary for the current row i.e. if the object is missing.- Specified by:
resolveKey
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- Overrides:
resolveKey
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveState
public void resolveState(Data data)
- Specified by:
resolveState
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- Overrides:
resolveState
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveFromPreviousRow
public void resolveFromPreviousRow(Data data)
Description copied from interface:Initializer
Step 1.2 - Special variant ofInitializer.resolveKey(InitializerData)
that allows the reuse of key value and instance value from the previous row.- Specified by:
resolveFromPreviousRow
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- Overrides:
resolveFromPreviousRow
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveInstance
public void resolveInstance(Data data)
Description copied from interface:Initializer
Step 2.1 - Using the key resolved inInitializer.resolveKey(Data)
, resolve the instance (of the thing initialized) to use for the current row. After this point, the initializer knows the entity/collection/component instance for the current row based on the resolved key. If the resolving was successful,Initializer.getResolvedInstance(RowProcessingState)
will return that instance.- Specified by:
resolveInstance
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
initializeShallowCached
protected void initializeShallowCached(Data data)
-
setMissing
protected void setMissing(Data data)
- Overrides:
setMissing
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveInstance
public void resolveInstance(Object instance, Data data)
Description copied from interface:Initializer
Step 2.2 - Use the given instance as resolved instance for this initializer. Initializers are supposed to recursively call this method for sub-initializers. This alternative initialization protocol is used when a parent instance was already part of the persistence context.- Specified by:
resolveInstance
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
resolveInstanceSubInitializers
protected abstract void resolveInstanceSubInitializers(Data data)
-
takeResponsibility
protected void takeResponsibility(Data data)
-
initializeInstance
public void initializeInstance(Data data)
Description copied from interface:Initializer
Step 3 - Initialize the state of the instance resolved inInitializer.resolveInstance(Data)
from the current row values. All resolved state for the current row is injected into the resolved instance- Specified by:
initializeInstance
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- Overrides:
initializeInstance
in classAbstractInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
initializeInstanceFromParent
public void initializeInstanceFromParent(Object parentInstance, Data data)
Description copied from interface:Initializer
Step 3.1 - Initialize the state of the instance as extracted from the given parentInstance. Extraction can be done with theInitializer.getInitializedPart()
. Initializers are supposed to recursively call this method for sub-initializers. This alternative initialization protocol is used for shallow query cache hits, in which case there is no data available in theJdbcValuesCacheHit
to initialize potentially lazy associations.- Specified by:
initializeInstanceFromParent
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
hasLazySubInitializers
public boolean hasLazySubInitializers()
Description copied from interface:Initializer
Indicates whether this initializer has sub-initializers which are lazy.- Specified by:
hasLazySubInitializers
in interfaceInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
- Overrides:
hasLazySubInitializers
in classAbstractCollectionInitializer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData>
-
accept
public void accept(Data data, List<Object> objects)
- Specified by:
accept
in interfaceBiConsumer<Data extends AbstractImmediateCollectionInitializer.ImmediateCollectionInitializerData,List<Object>>
-
initializeSubInstancesFromParent
protected abstract void initializeSubInstancesFromParent(Data data)
-
getIndexAssembler
public abstract @Nullable DomainResultAssembler<?> getIndexAssembler()
-
getElementAssembler
public abstract DomainResultAssembler<?> getElementAssembler()
-
-