Top Fields Constructors Methods
org.hibernate.sql.results.graph.entity

public abstract Class AbstractEntityInitializer

extends AbstractFetchParentAccess
implements EntityInitializer
Class Inheritance
All Implemented Interfaces
org.hibernate.sql.results.graph.entity.EntityInitializer, org.hibernate.sql.results.graph.FetchParentAccess, org.hibernate.sql.results.graph.Initializer
Known Direct Subclasses
org.hibernate.sql.results.graph.entity.internal.EntityJoinedFetchInitializer, org.hibernate.sql.results.graph.entity.internal.EntityResultInitializer
Imports
java.util.Collection, java.util.function.Consumer, org.hibernate.Hibernate, .HibernateException, .LockMode, .StaleObjectStateException, .WrongClassException, org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer, org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor, org.hibernate.cache.spi.access.EntityDataAccess, org.hibernate.cache.spi.entry.CacheEntry, org.hibernate.engine.spi.EntityEntry, .EntityHolder, .EntityKey, .EntityUniqueKey, .PersistenceContext, .PersistentAttributeInterceptor, .SessionEventListenerManager, .SessionFactoryImplementor, .SharedSessionContractImplementor, .Status, org.hibernate.event.spi.EventManager, .HibernateMonitoringEvent, .PreLoadEvent, .PreLoadEventListener, org.hibernate.internal.util.StringHelper, org.hibernate.loader.ast.internal.CacheEntityLoaderHelper, org.hibernate.metamodel.mapping.AttributeMapping, .AttributeMetadata, .EntityDiscriminatorMapping, .DiscriminatorValueDetails, .EntityMappingType, .EntityValuedModelPart, .EntityVersionMapping, .ManagedMappingType, .ModelPart, org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping, org.hibernate.persister.entity.EntityPersister, .UniqueKeyEntry, org.hibernate.property.access.internal.PropertyAccessStrategyBackRefImpl, org.hibernate.proxy.LazyInitializer, org.hibernate.proxy.map.MapProxy, org.hibernate.spi.NavigablePath, org.hibernate.sql.exec.spi.ExecutionContext, org.hibernate.sql.results.graph.AbstractFetchParentAccess, .AssemblerCreationState, .DomainResult, .DomainResultAssembler, .Fetch, .Initializer, org.hibernate.sql.results.graph.basic.BasicResultAssembler, org.hibernate.sql.results.graph.embeddable.internal.EmbeddableAssembler, org.hibernate.sql.results.internal.NullValueAssembler, org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions, .JdbcValuesSourceProcessingState, .RowProcessingState, org.hibernate.stat.spi.StatisticsImplementor, org.hibernate.type.Type

Authors
Steve Ebersole, Nathan Xu

Field Summary

Modifier and TypeField and Description
private final DomainResultAssembler<?>[][]
private EntityPersister
private final BasicResultAssembler<?>
private final EntityPersister
private Object
private Object
private EntityKey
private final DomainResultAssembler<?>
pack-priv boolean
private boolean
private final LockMode
protected boolean
private final EntityValuedModelPart
private Object[]
private final EntityPersister
private final DomainResultAssembler<Object>
private Object
private final DomainResultAssembler<?>

Constructor Summary

AccessConstructor and Description
protected
AbstractEntityInitializer(EntityResultGraphNode resultDescriptor, NavigablePath navigablePath, LockMode lockMode, Fetch identifierFetch, Fetch discriminatorFetch, DomainResult<Object> rowIdResult, AssemblerCreationState creationState)

Method Summary

Modifier and TypeMethod and Description
private void
checkVersion(EntityEntry entry, final RowProcessingState rowProcessingState)

Check the version of the object in the RowProcessingState against the object version in the session cache, throwing an exception if the version numbers are different

protected boolean
consistentInstance(Object toInitialize, RowProcessingState rowProcessingState)

private static Object
copy(AttributeMetadata attributeMetadata, Object sourceValue)

private static void
deepCopy(ManagedMappingType containerDescriptor, Object[] source, Object[] target)

private EntityPersister
protected Object[]
public void
finishUpRow(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.finishUpRow.

Lifecycle method called at the end of the current row processing.
protected DomainResultAssembler<?>[][]
public EntityPersister
public EntityPersister
getEntityDescriptor()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityDescriptor.

Get the descriptor for the type of entity being initialized
protected Object
public Object
getEntityInstance()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityInstance.

Get the entity instance for the currently processing "row".
protected Object
public EntityKey
protected DomainResultAssembler<?>
public ModelPart
public Object
protected LockMode
public NavigablePath
public Object
protected Object[]
protected DomainResultAssembler<Object>
protected abstract String
getSimpleConcreteImplName()

Simple class name of this initializer for logging

protected DomainResultAssembler<?>
private void
initializeEntity(Object toInitialize, RowProcessingState rowProcessingState)

private void
initializeEntityInstance(Object toInitialize, RowProcessingState rowProcessingState)

private Object
public void
initializeInstance(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.initializeInstance.

Step 3 - Initialize the state of the instance resolved in resolveInstance from the current row values.
protected Object
public boolean
protected abstract boolean
private boolean
protected boolean
private boolean
private boolean
isReadOnly(RowProcessingState rowProcessingState, SharedSessionContractImplementor persistenceContext)

private boolean
private boolean
isReferencedModelPartInConcreteParent(ModelPart modelPart, NavigablePath partNavigablePath, Initializer parentInitializer)

private boolean
protected void
preLoad(RowProcessingState rowProcessingState)

private void
putInCache(Object toInitialize, SharedSessionContractImplementor session, PersistenceContext persistenceContext, Object entityIdentifier, Object version, EntityDataAccess cacheAccess)

protected void
registerLoadingEntity(RowProcessingState rowProcessingState, Object instance)

protected abstract void
protected void
registerNaturalIdResolution(PersistenceContext persistenceContext, Object entityIdentifier)

protected void
protected void
protected void
public void
protected void
resolveEntityInstance(RowProcessingState rowProcessingState, EntityHolder holder, Object entityIdentifier)

protected Object
resolveEntityInstance(Object entityIdentifier, RowProcessingState rowProcessingState)

protected void
public void
resolveInstance(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.resolveInstance.

Step 2 - Using the key resolved in resolveKey, resolve the instance (of the thing initialized) to use for the current row.
protected Object
resolveInstance(Object entityIdentifier, EntityHolder holder, RowProcessingState rowProcessingState)

Used by Hibernate Reactive

private Object
public void
resolveKey(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.resolveKey.

Step 1 - Resolve the key value for this initializer for the current row.
private void
resolveState(RowProcessingState rowProcessingState)

private Object
protected void
setEntityInitialized(boolean isInitialized)

protected void
setEntityInstanceForNotify(Object entityInstanceForNotify)

protected void
setMissing(boolean missing)

protected void
setResolvedEntityState(Object[] resolvedEntityState)

protected boolean
protected boolean
skipInitialization(Object toInitialize, RowProcessingState rowProcessingState)

protected void
takeSnapshot(RowProcessingState rowProcessingState, SharedSessionContractImplementor session, PersistenceContext persistenceContext, EntityEntry entityEntry)

protected void
updateCaches(Object toInitialize, RowProcessingState rowProcessingState, SharedSessionContractImplementor session, PersistenceContext persistenceContext, Object entityIdentifier, Object version)

private void
upgradeLockMode(RowProcessingState rowProcessingState)

private boolean
Inherited from org.hibernate.sql.results.graph.AbstractFetchParentAccess:
clearResolutionListenersnotifyResolutionListeners

Field Detail

assemblersback to summary
private final DomainResultAssembler<?>[][] assemblers
concreteDescriptorback to summary
private EntityPersister concreteDescriptor
discriminatorAssemblerback to summary
private final BasicResultAssembler<?> discriminatorAssembler
entityDescriptorback to summary
private final EntityPersister entityDescriptor
entityInstanceback to summary
private Object entityInstance
entityInstanceForNotifyback to summary
private Object entityInstanceForNotify
entityKeyback to summary
private EntityKey entityKey
identifierAssemblerback to summary
private final DomainResultAssembler<?> identifierAssembler
isInitializedback to summary
pack-priv boolean isInitialized
isOwningInitializerback to summary
private boolean isOwningInitializer
lockModeback to summary
private final LockMode lockMode
missingback to summary
protected boolean missing
referencedModelPartback to summary
private final EntityValuedModelPart referencedModelPart
resolvedEntityStateback to summary
private Object[] resolvedEntityState
rootEntityDescriptorback to summary
private final EntityPersister rootEntityDescriptor
rowIdAssemblerback to summary
private final DomainResultAssembler<Object> rowIdAssembler
versionback to summary
private Object version
versionAssemblerback to summary
private final DomainResultAssembler<?> versionAssembler

Constructor Detail

AbstractEntityInitializerback to summary
protected AbstractEntityInitializer(EntityResultGraphNode resultDescriptor, NavigablePath navigablePath, LockMode lockMode, Fetch identifierFetch, Fetch discriminatorFetch, DomainResult<Object> rowIdResult, AssemblerCreationState creationState)

Method Detail

checkVersionback to summary
private void checkVersion(EntityEntry entry, final RowProcessingState rowProcessingState) throws HibernateException

Check the version of the object in the RowProcessingState against the object version in the session cache, throwing an exception if the version numbers are different

consistentInstanceback to summary
protected boolean consistentInstance(Object toInitialize, RowProcessingState rowProcessingState)
copyback to summary
private static Object copy(AttributeMetadata attributeMetadata, Object sourceValue)
Annotations
@SuppressWarnings:unchecked
deepCopyback to summary
private static void deepCopy(ManagedMappingType containerDescriptor, Object[] source, Object[] target)
determineConcreteEntityDescriptorback to summary
private EntityPersister determineConcreteEntityDescriptor(RowProcessingState rowProcessingState) throws WrongClassException
extractConcreteTypeStateValuesback to summary
protected Object[] extractConcreteTypeStateValues(RowProcessingState rowProcessingState)
finishUpRowback to summary
public void finishUpRow(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.finishUpRow.

Doc from org.hibernate.sql.results.graph.Initializer.finishUpRow.

Lifecycle method called at the end of the current row processing. Provides ability to complete processing from the current row and prepare for the next row.

Annotations
@Override
getAssemblersback to summary
protected DomainResultAssembler<?>[][] getAssemblers()
getConcreteDescriptorback to summary
public EntityPersister getConcreteDescriptor()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getConcreteDescriptor.

Annotations
@Override
getEntityDescriptorback to summary
public EntityPersister getEntityDescriptor()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityDescriptor.

Doc from org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityDescriptor.

Get the descriptor for the type of entity being initialized

Annotations
@Override
getEntityFromExecutionContextback to summary
protected Object getEntityFromExecutionContext(RowProcessingState rowProcessingState)
getEntityInstanceback to summary
public Object getEntityInstance()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityInstance.

Doc from org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityInstance.

Get the entity instance for the currently processing "row".

Annotations
@Override
getEntityInstanceForNotifyback to summary
protected Object getEntityInstanceForNotify()
getEntityKeyback to summary
public EntityKey getEntityKey()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.getEntityKey.

Annotations
@Override
getIdentifierAssemblerback to summary
protected DomainResultAssembler<?> getIdentifierAssembler()
getInitializedPartback to summary
public ModelPart getInitializedPart()

Implements org.hibernate.sql.results.graph.Initializer.getInitializedPart.

Annotations
@Override
getKeyValueback to summary
public Object getKeyValue()
Annotations
@SuppressWarnings:unused
getLockModeback to summary
protected LockMode getLockMode()
getNavigablePathback to summary
public NavigablePath getNavigablePath()

Implements org.hibernate.sql.results.graph.FetchParentAccess.getNavigablePath.

getParentKeyback to summary
public Object getParentKey()

Implements org.hibernate.sql.results.graph.FetchParentAccess.getParentKey.

Annotations
@Override
getResolvedEntityStateback to summary
protected Object[] getResolvedEntityState()
getRowIdAssemblerback to summary
protected DomainResultAssembler<Object> getRowIdAssembler()
getSimpleConcreteImplNameback to summary
protected abstract String getSimpleConcreteImplName()

Simple class name of this initializer for logging

getVersionAssemblerback to summary
protected DomainResultAssembler<?> getVersionAssembler()
initializeEntityback to summary
private void initializeEntity(Object toInitialize, RowProcessingState rowProcessingState)
initializeEntityInstanceback to summary
private void initializeEntityInstance(Object toInitialize, RowProcessingState rowProcessingState)
initializeIdentifierback to summary
private Object initializeIdentifier(RowProcessingState rowProcessingState)
initializeInstanceback to summary
public void initializeInstance(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.initializeInstance.

Doc from org.hibernate.sql.results.graph.Initializer.initializeInstance.

Step 3 - Initialize the state of the instance resolved in resolveInstance from the current row values. All resolved state for the current row is injected into the resolved instance

Annotations
@Override
instantiateEntityback to summary
protected Object instantiateEntity(Object entityIdentifier, SharedSessionContractImplementor session)
isEntityInitializedback to summary
public boolean isEntityInitialized()

Implements org.hibernate.sql.results.graph.entity.EntityInitializer.isEntityInitialized.

Returns:boolean

Doc from org.hibernate.sql.results.graph.entity.EntityInitializer.isEntityInitialized.

true if the current entity associated to this EntityInitializer has been initialized

Annotations
@Override
isEntityReturnback to summary
protected abstract boolean isEntityReturn()
isExistingEntityInitializedback to summary
private boolean isExistingEntityInitialized(Object existingEntity)
isMissingback to summary
protected boolean isMissing()
isProxyInstanceback to summary
private boolean isProxyInstance(Object proxy)
isReadOnlyback to summary
private boolean isReadOnly(RowProcessingState rowProcessingState, SharedSessionContractImplementor persistenceContext)
isReallyReadOnlyback to summary
private boolean isReallyReadOnly(RowProcessingState rowProcessingState, SharedSessionContractImplementor session)
isReferencedModelPartInConcreteParentback to summary
private boolean isReferencedModelPartInConcreteParent(ModelPart modelPart, NavigablePath partNavigablePath, Initializer parentInitializer)
matchesOptionalInstanceback to summary
private boolean matchesOptionalInstance(JdbcValuesSourceProcessingOptions processingOptions)
preLoadback to summary
protected void preLoad(RowProcessingState rowProcessingState)
putInCacheback to summary
private void putInCache(Object toInitialize, SharedSessionContractImplementor session, PersistenceContext persistenceContext, Object entityIdentifier, Object version, EntityDataAccess cacheAccess)
registerLoadingEntityback to summary
protected void registerLoadingEntity(RowProcessingState rowProcessingState, Object instance)
registerLoadingEntityInstanceFromExecutionContextback to summary
protected abstract void registerLoadingEntityInstanceFromExecutionContext(RowProcessingState rowProcessingState, Object instance)
registerNaturalIdResolutionback to summary
protected void registerNaturalIdResolution(PersistenceContext persistenceContext, Object entityIdentifier)
registerPossibleUniqueKeyEntriesback to summary
protected void registerPossibleUniqueKeyEntries(final Object toInitialize, final SharedSessionContractImplementor session)
registerReloadedEntityback to summary
protected void registerReloadedEntity(RowProcessingState rowProcessingState)
registerReloadedEntityback to summary
protected void registerReloadedEntity(RowProcessingState rowProcessingState, EntityHolder holder)
registerResolutionListenerback to summary
public void registerResolutionListener(Consumer<Object> listener)

Overrides org.hibernate.sql.results.graph.AbstractFetchParentAccess.registerResolutionListener.

Implements org.hibernate.sql.results.graph.FetchParentAccess.registerResolutionListener.

Doc from org.hibernate.sql.results.graph.FetchParentAccess.registerResolutionListener.

Register a listener to be notified when the parent is "resolved"

Annotations
@Override
resolveEntityInstanceback to summary
protected void resolveEntityInstance(RowProcessingState rowProcessingState, EntityHolder holder, Object entityIdentifier)
resolveEntityInstanceback to summary
protected Object resolveEntityInstance(Object entityIdentifier, RowProcessingState rowProcessingState)
resolveEntityKeyback to summary
protected void resolveEntityKey(RowProcessingState rowProcessingState)
resolveInstanceback to summary
public void resolveInstance(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.resolveInstance.

Doc from org.hibernate.sql.results.graph.Initializer.resolveInstance.

Step 2 - Using the key resolved in resolveKey, 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 todo (6.0) : much of the various implementations of this are similar enough to handle in a common base implementation (templating?) things like resolving as managed (Session cache), from second-level cache, from LoadContext, etc..

Annotations
@Override
resolveInstanceback to summary
protected Object resolveInstance(Object entityIdentifier, EntityHolder holder, RowProcessingState rowProcessingState)

Used by Hibernate Reactive

resolveInstanceFromCacheback to summary
private Object resolveInstanceFromCache(RowProcessingState rowProcessingState)
resolveKeyback to summary
public void resolveKey(RowProcessingState rowProcessingState)

Implements org.hibernate.sql.results.graph.Initializer.resolveKey.

Doc from org.hibernate.sql.results.graph.Initializer.resolveKey.

Step 1 - Resolve the key value for this initializer for the current row. After this point, the initializer knows the entity/collection/component key for the current row

Annotations
@Override
resolveStateback to summary
private void resolveState(RowProcessingState rowProcessingState)
resolveToOptionalInstanceback to summary
private Object resolveToOptionalInstance(RowProcessingState rowProcessingState)
setEntityInitializedback to summary
protected void setEntityInitialized(boolean isInitialized)
setEntityInstanceForNotifyback to summary
protected void setEntityInstanceForNotify(Object entityInstanceForNotify)
setMissingback to summary
protected void setMissing(boolean missing)
setResolvedEntityStateback to summary
protected void setResolvedEntityState(Object[] resolvedEntityState)
shouldSkipResolveInstanceback to summary
protected boolean shouldSkipResolveInstance(RowProcessingState rowProcessingState)
skipInitializationback to summary
protected boolean skipInitialization(Object toInitialize, RowProcessingState rowProcessingState)
takeSnapshotback to summary
protected void takeSnapshot(RowProcessingState rowProcessingState, SharedSessionContractImplementor session, PersistenceContext persistenceContext, EntityEntry entityEntry)
updateCachesback to summary
protected void updateCaches(Object toInitialize, RowProcessingState rowProcessingState, SharedSessionContractImplementor session, PersistenceContext persistenceContext, Object entityIdentifier, Object version)
upgradeLockModeback to summary
private void upgradeLockMode(RowProcessingState rowProcessingState)
useEmbeddedIdentifierInstanceAsEntityback to summary
private boolean useEmbeddedIdentifierInstanceAsEntity(Object id)