Java 类org.hibernate.event.PostLoadEvent 实例源码

项目:cacheonix-core    文件:DefaultPostLoadEventListener.java   
public void onPostLoad(PostLoadEvent event) {
    if ( event.getPersister().implementsLifecycle( event.getSession().getEntityMode() ) ) {
        //log.debug( "calling onLoad()" );
        ( ( Lifecycle ) event.getEntity() ).onLoad( event.getSession(), event.getId() );
    }

}
项目:caarray    文件:SecurityPolicyPostLoadEventListener.java   
/**
 * {@inheritDoc}
 */
public void onPostLoad(PostLoadEvent event) {
    if (SecurityUtils.isPrivilegedMode()) {
        return;
    }

    if (event.getEntity() instanceof AbstractCaArrayObject) {
        AbstractCaArrayObject object = (AbstractCaArrayObject) event.getEntity();
        Set<SecurityPolicy> policies = object.getPostLoadSecurityPolicies(CaArrayUsernameHolder.getCsmUser());
        if (!policies.isEmpty()) {
            SecurityPolicy.applySecurityPolicies(object, policies);
        }
    }
}
项目:cacheonix-core    文件:DefaultLoadEventListener.java   
private Object assembleCacheEntry(
        final CacheEntry entry,
        final Serializable id,
        final EntityPersister persister,
        final LoadEvent event) throws HibernateException {

    final Object optionalObject = event.getInstanceToLoad();
    final EventSource session = event.getSession();
    final SessionFactoryImplementor factory = session.getFactory();

    if ( log.isTraceEnabled() ) {
        log.trace(
                "assembling entity from second-level cache: " +
                MessageHelper.infoString( persister, id, factory )
            );
    }

    EntityPersister subclassPersister = factory.getEntityPersister( entry.getSubclass() );
    Object result = optionalObject == null ? 
            session.instantiate( subclassPersister, id ) : optionalObject;

    // make it circular-reference safe
    TwoPhaseLoad.addUninitializedCachedEntity( 
            new EntityKey( id, subclassPersister, session.getEntityMode() ), 
            result, 
            subclassPersister, 
            LockMode.NONE, 
            entry.areLazyPropertiesUnfetched(),
            entry.getVersion(),
            session
        );

    Type[] types = subclassPersister.getPropertyTypes();
    Object[] values = entry.assemble( result, id, subclassPersister, session.getInterceptor(), session ); // intializes result by side-effect
    TypeFactory.deepCopy( 
            values, 
            types, 
            subclassPersister.getPropertyUpdateability(), 
            values, 
            session
        );

    Object version = Versioning.getVersion( values, subclassPersister );
    if ( log.isTraceEnabled() ) log.trace( "Cached Version: " + version );

    final PersistenceContext persistenceContext = session.getPersistenceContext();
    persistenceContext.addEntry( 
            result, 
            Status.MANAGED, 
            values, 
            null, 
            id, 
            version, 
            LockMode.NONE, 
            true, 
            subclassPersister, 
            false, 
            entry.areLazyPropertiesUnfetched() 
        );
    subclassPersister.afterInitialize( result, entry.areLazyPropertiesUnfetched(), session );
    persistenceContext.initializeNonLazyCollections();
    // upgrade the lock if necessary:
    //lock(result, lockMode);

    //PostLoad is needed for EJB3
    //TODO: reuse the PostLoadEvent...
    PostLoadEvent postLoadEvent = new PostLoadEvent(session).setEntity(result)
            .setId(id).setPersister(persister);
    PostLoadEventListener[] listeners = session.getListeners().getPostLoadEventListeners();
    for ( int i = 0; i < listeners.length; i++ ) {
        listeners[i].onPostLoad(postLoadEvent);
    }

    return result;
}
项目:cacheonix-core    文件:CustomPersister.java   
/**
 * @see EntityPersister#load(Serializable, Object, LockMode, SessionImplementor)
 */
public Object load(
    Serializable id,
    Object optionalObject,
    LockMode lockMode,
    SessionImplementor 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(
                new EntityKey( id, this, session.getEntityMode() ),
                clone,
                this,
                LockMode.NONE,
                false,
                session
            );
        TwoPhaseLoad.postHydrate(
                this, id,
                new String[] { obj.getName() },
                null,
                clone,
                LockMode.NONE,
                false,
                session
            );
        TwoPhaseLoad.initializeEntity(
                clone,
                false,
                session,
                new PreLoadEvent( (EventSource) session ),
                new PostLoadEvent( (EventSource) session )
            );
    }
    return clone;
}
项目:Lucee4    文件:AllEventListener.java   
public void onPostLoad(PostLoadEvent event) {
    invoke(CommonUtil.POST_LOAD, event.getEntity());
}
项目:Lucee4    文件:PostLoadEventListenerImpl.java   
public void onPostLoad(PostLoadEvent event) {
    invoke(CommonUtil.POST_LOAD, event.getEntity());
}
项目:screensaver    文件:AbstractManagedEventsListener.java   
@Override
public void onPostLoad(PostLoadEvent event)
{
  apply(event.getEntity());
}