org.hibernate.engine.internal
Class TwoPhaseLoad

java.lang.Object
  extended by org.hibernate.engine.internal.TwoPhaseLoad

public final class TwoPhaseLoad
extends Object

Functionality relating to Hibernate's two-phase loading process, that may be reused by persisters that do not use the Loader framework


Method Summary
static void addUninitializedCachedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, boolean lazyPropertiesAreUnfetched, Object version, SessionImplementor session)
           
static void addUninitializedEntity(EntityKey key, Object object, EntityPersister persister, LockMode lockMode, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
          Add an uninitialized instance of an entity class, as a placeholder to ensure object identity.
static void initializeEntity(Object entity, boolean readOnly, SessionImplementor session, PreLoadEvent preLoadEvent, PostLoadEvent postLoadEvent)
          Perform the second step of 2-phase load.
static void postHydrate(EntityPersister persister, Serializable id, Object[] values, Object rowId, Object object, LockMode lockMode, boolean lazyPropertiesAreUnfetched, SessionImplementor session)
          Register the "hydrated" state of an entity instance, after the first step of 2-phase loading.
static void postLoad(Object entity, SessionImplementor session, PostLoadEvent postLoadEvent)
          PostLoad cannot occur during initializeEntity, as that call occurs *before* the Set collections are added to the persistence context by Loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

postHydrate

public static void postHydrate(EntityPersister persister,
                               Serializable id,
                               Object[] values,
                               Object rowId,
                               Object object,
                               LockMode lockMode,
                               boolean lazyPropertiesAreUnfetched,
                               SessionImplementor session)
                        throws HibernateException
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

Throws:
HibernateException

initializeEntity

public static void initializeEntity(Object entity,
                                    boolean readOnly,
                                    SessionImplementor session,
                                    PreLoadEvent preLoadEvent,
                                    PostLoadEvent postLoadEvent)
                             throws HibernateException
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

Throws:
HibernateException

postLoad

public static void postLoad(Object entity,
                            SessionImplementor session,
                            PostLoadEvent postLoadEvent)
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

Parameters:
entity -
session -
postLoadEvent -

addUninitializedEntity

public static void addUninitializedEntity(EntityKey key,
                                          Object object,
                                          EntityPersister persister,
                                          LockMode lockMode,
                                          boolean lazyPropertiesAreUnfetched,
                                          SessionImplementor 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.


addUninitializedCachedEntity

public static void addUninitializedCachedEntity(EntityKey key,
                                                Object object,
                                                EntityPersister persister,
                                                LockMode lockMode,
                                                boolean lazyPropertiesAreUnfetched,
                                                Object version,
                                                SessionImplementor session)


Copyright © 2001-2013 Red Hat, Inc. All Rights Reserved.