public void onPostLoad(PostLoadEvent event) { if ( event.getPersister().implementsLifecycle( event.getSession().getEntityMode() ) ) { //log.debug( "calling onLoad()" ); ( ( Lifecycle ) event.getEntity() ).onLoad( event.getSession(), event.getId() ); } }
/** * {@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); } } }
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; }
/** * @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; }
public void onPostLoad(PostLoadEvent event) { invoke(CommonUtil.POST_LOAD, event.getEntity()); }
@Override public void onPostLoad(PostLoadEvent event) { apply(event.getEntity()); }