类 TwoPhaseLoad
- java.lang.Object
-
- org.hibernate.engine.internal.TwoPhaseLoad
-
public final class TwoPhaseLoad extends Object
Functionality relating to the Hibernate two-phase loading process, that may be reused by persisters that do not use the Loader framework- 作者:
- Gavin King
-
-
方法概要
所有方法 静态方法 具体方法 已过时的方法 修饰符和类型 方法 说明 static voidaddUninitializedCachedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, Object version, SharedSessionContractImplementor session)Same asaddUninitializedEntity(org.hibernate.engine.spi.EntityKey, java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.LockMode, org.hibernate.engine.spi.SharedSessionContractImplementor), but here for an entity from the second level cachestatic voidaddUninitializedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, SharedSessionContractImplementor session)Add an uninitialized instance of an entity class, as a placeholder to ensure object identity.static voidafterInitialize(Object entity, SharedSessionContractImplementor session)Perform the afterInitialize() step.static voidinitializeEntity(Object entity, boolean readOnly, SharedSessionContractImplementor session, PreLoadEvent preLoadEvent)已过时。This method will be removed.static voidinitializeEntity(Object entity, boolean readOnly, SharedSessionContractImplementor session, PreLoadEvent preLoadEvent, Iterable<PreLoadEventListener> preLoadEventListeners)Perform the second step of 2-phase load.static voidpostHydrate(EntityPersister persister, Serializable id, Object[] values, Object rowId, Object object, LockMode lockMode, SharedSessionContractImplementor session)Register the "hydrated" state of an entity instance, after the first step of 2-phase loading.static voidpostLoad(Object entity, SharedSessionContractImplementor session, PostLoadEvent postLoadEvent)static voidpostLoad(Object entity, SharedSessionContractImplementor session, PostLoadEvent postLoadEvent, Iterable<PostLoadEventListener> postLoadEventListeners)PostLoad cannot occur during initializeEntity, as that call occurs *before* the Set collections are added to the persistence context by Loader.
-
-
-
方法详细资料
-
postHydrate
public static void postHydrate(EntityPersister persister, Serializable id, Object[] values, Object rowId, Object object, LockMode lockMode, SharedSessionContractImplementor session)
Register the "hydrated" state of an entity instance, after the first step of 2-phase loading. Add the "hydrated state" (an array) of an uninitialized entity to the session. We don't try to resolve any associations yet, because there might be other entities waiting to be read from the JDBC result set we are currently processing- 参数:
persister- The persister for the hydrated entityid- The entity identifiervalues- The entity valuesrowId- The rowId for the entityobject- An optional instance for the entity being loadedlockMode- The lock modesession- The Session
-
initializeEntity
@Deprecated public static void initializeEntity(Object entity, boolean readOnly, SharedSessionContractImplementor session, PreLoadEvent preLoadEvent)
已过时。This method will be removed. UseinitializeEntity(Object, boolean, SharedSessionContractImplementor, PreLoadEvent, Iterable)instead.- 参数:
entity- The entity being loadedreadOnly- Is the entity being loaded as read-onlysession- The SessionpreLoadEvent- The (re-used) pre-load event
-
initializeEntity
public static void initializeEntity(Object entity, boolean readOnly, SharedSessionContractImplementor session, PreLoadEvent preLoadEvent, Iterable<PreLoadEventListener> preLoadEventListeners)
Perform the second step of 2-phase load. Fully initialize the entity instance. After processing a JDBC result set, we "resolve" all the associations between the entities which were instantiated and had their state "hydrated" into an array- 参数:
entity- The entity being loadedreadOnly- Is the entity being loaded as read-onlysession- The SessionpreLoadEvent- The (re-used) pre-load eventpreLoadEventListeners- the pre-load event listeners
-
afterInitialize
public static void afterInitialize(Object entity, SharedSessionContractImplementor session)
Perform the afterInitialize() step. This needs to be done after the collections have been properly initialized thus a separate step.- 参数:
entity- The entity being loadedsession- The Session
-
postLoad
public static void postLoad(Object entity, SharedSessionContractImplementor session, PostLoadEvent postLoadEvent, Iterable<PostLoadEventListener> postLoadEventListeners)
PostLoad cannot occur during initializeEntity, as that call occurs *before* the Set collections are added to the persistence context by Loader. Without the split, LazyInitializationExceptions can occur in the Entity's postLoad if it acts upon the collection. HHH-6043- 参数:
entity- The entitysession- The SessionpostLoadEvent- The (re-used) post-load event
-
postLoad
@Deprecated public static void postLoad(Object entity, SharedSessionContractImplementor session, PostLoadEvent postLoadEvent)
This method will be removed.
-
addUninitializedEntity
public static void addUninitializedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, SharedSessionContractImplementor session)
Add an uninitialized instance of an entity class, as a placeholder to ensure object identity. Must be called before postHydrate(). Create a "temporary" entry for a newly instantiated entity. The entity is uninitialized, but we need the mapping from id to instance in order to guarantee uniqueness.- 参数:
key- The entity keyobject- The entity instancepersister- The entity persisterlockMode- The lock modesession- The Session
-
addUninitializedCachedEntity
public static void addUninitializedCachedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, Object version, SharedSessionContractImplementor session)
Same asaddUninitializedEntity(org.hibernate.engine.spi.EntityKey, java.lang.Object, org.hibernate.persister.entity.EntityPersister, org.hibernate.LockMode, org.hibernate.engine.spi.SharedSessionContractImplementor), but here for an entity from the second level cache- 参数:
key- The entity keyobject- The entity instancepersister- The entity persisterlockMode- The lock modeversion- The versionsession- The Session
-
-