Search in sources :

Example 36 with EventSource

use of org.hibernate.event.spi.EventSource in project hibernate-orm by hibernate.

the class CustomPersister method load.

/**
	 * @see EntityPersister#load(Serializable, Object, LockMode, SharedSessionContractImplementor)
	 */
public Object load(Serializable id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session) throws HibernateException {
    // fails when optional object is supplied
    Custom clone = null;
    Custom obj = (Custom) INSTANCES.get(id);
    if (obj != null) {
        clone = (Custom) obj.clone();
        TwoPhaseLoad.addUninitializedEntity(session.generateEntityKey(id, this), clone, this, LockMode.NONE, session);
        TwoPhaseLoad.postHydrate(this, id, new String[] { obj.getName() }, null, clone, LockMode.NONE, session);
        TwoPhaseLoad.initializeEntity(clone, false, session, new PreLoadEvent((EventSource) session));
        TwoPhaseLoad.postLoad(clone, session, new PostLoadEvent((EventSource) session));
    }
    return clone;
}
Also used : PostLoadEvent(org.hibernate.event.spi.PostLoadEvent) EventSource(org.hibernate.event.spi.EventSource) PreLoadEvent(org.hibernate.event.spi.PreLoadEvent)

Aggregations

EventSource (org.hibernate.event.spi.EventSource)36 EntityPersister (org.hibernate.persister.entity.EntityPersister)15 Serializable (java.io.Serializable)10 EntityEntry (org.hibernate.engine.spi.EntityEntry)10 EntityKey (org.hibernate.engine.spi.EntityKey)8 PersistenceContext (org.hibernate.engine.spi.PersistenceContext)7 PostLoadEvent (org.hibernate.event.spi.PostLoadEvent)5 HibernateProxy (org.hibernate.proxy.HibernateProxy)4 AssertionFailure (org.hibernate.AssertionFailure)3 HibernateException (org.hibernate.HibernateException)3 Status (org.hibernate.engine.spi.Status)3 PreLoadEvent (org.hibernate.event.spi.PreLoadEvent)3 CollectionPersister (org.hibernate.persister.collection.CollectionPersister)3 Type (org.hibernate.type.Type)3 TransientObjectException (org.hibernate.TransientObjectException)2 PersistentCollection (org.hibernate.collection.spi.PersistentCollection)2 CascadePoint (org.hibernate.engine.internal.CascadePoint)2 StatefulPersistenceContext (org.hibernate.engine.internal.StatefulPersistenceContext)2 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)2 EventType (org.hibernate.event.spi.EventType)2