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

项目:lams    文件:TwoPhaseLoad.java   
/**
 * 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
 * 
 * @param entity The entity
 * @param session The Session
 * @param postLoadEvent The (re-used) post-load event
 */
public static void postLoad(
        final Object entity,
        final SessionImplementor session,
        final PostLoadEvent postLoadEvent) {

    if ( session.isEventSource() ) {
        final PersistenceContext persistenceContext
                = session.getPersistenceContext();
        final EntityEntry entityEntry = persistenceContext.getEntry( entity );

        postLoadEvent.setEntity( entity ).setId( entityEntry.getId() ).setPersister( entityEntry.getPersister() );

        final EventListenerGroup<PostLoadEventListener> listenerGroup = session.getFactory()
                        .getServiceRegistry()
                        .getService( EventListenerRegistry.class )
                        .getEventListenerGroup( EventType.POST_LOAD );
        for ( PostLoadEventListener listener : listenerGroup.listeners() ) {
            listener.onPostLoad( postLoadEvent );
        }
    }
}
项目:lams    文件:AbstractRowReader.java   
private void postLoad(
        PostLoadEvent postLoadEvent,
        ResultSetProcessingContextImpl context,
        List<HydratedEntityRegistration> hydratedEntityRegistrations,
        List<AfterLoadAction> afterLoadActionList) {
    // Until this entire method is refactored w/ polymorphism, postLoad was
    // split off from initializeEntity.  It *must* occur after
    // endCollectionLoad to ensure the collection is in the
    // persistence context.
    if ( hydratedEntityRegistrations == null ) {
        return;
    }

    for ( HydratedEntityRegistration registration : hydratedEntityRegistrations ) {
        TwoPhaseLoad.postLoad( registration.getInstance(), context.getSession(), postLoadEvent );
        if ( afterLoadActionList != null ) {
            for ( AfterLoadAction afterLoadAction : afterLoadActionList ) {
                afterLoadAction.afterLoad(
                        context.getSession(),
                        registration.getInstance(),
                        (Loadable) registration.getEntityReference().getEntityPersister()
                );
            }
        }
    }

}
项目:jspresso-ce    文件:LifecyclePostLoadEventListener.java   
/**
 * Retrieves the entity and triggers the onLoad lifecycle hook.
 * <p>
 * {@inheritDoc}
 */
@Override
public void onPostLoad(PostLoadEvent event) {
  Object entity = event.getEntity();
  if (entity instanceof ILifecycleCapable) {
    ((ILifecycleCapable) entity).onLoad();
  }
}
项目:lams    文件:DefaultPostLoadEventListener.java   
@Override
public void onPostLoad(PostLoadEvent event) {
    final Object entity = event.getEntity();
    final EntityEntry entry = event.getSession().getPersistenceContext().getEntry( entity );
    if ( entry == null ) {
        throw new AssertionFailure( "possible non-threadsafe access to the session" );
    }

    final LockMode lockMode = entry.getLockMode();
    if ( LockMode.PESSIMISTIC_FORCE_INCREMENT.equals( lockMode ) ) {
        final EntityPersister persister = entry.getPersister();
        final Object nextVersion = persister.forceVersionIncrement(
                entry.getId(),
                entry.getVersion(),
                event.getSession()
        );
        entry.forceLocked( entity, nextVersion );
    }
    else if ( LockMode.OPTIMISTIC_FORCE_INCREMENT.equals( lockMode ) ) {
        final EntityIncrementVersionProcess incrementVersion = new EntityIncrementVersionProcess( entity, entry );
        event.getSession().getActionQueue().registerProcess( incrementVersion );
    }
    else if ( LockMode.OPTIMISTIC.equals( lockMode ) ) {
        final EntityVerifyVersionProcess verifyVersion = new EntityVerifyVersionProcess( entity, entry );
        event.getSession().getActionQueue().registerProcess( verifyVersion );
    }

    if ( event.getPersister().implementsLifecycle() ) {
        //log.debug( "calling onLoad()" );
        ( (Lifecycle) event.getEntity() ).onLoad( event.getSession(), event.getId() );
    }

}
项目:spring-entity-listener    文件:HibernateEntityListenersAdapter.java   
/**
 * @see org.hibernate.event.spi.PostLoadEventListener#onPostLoad(org.hibernate
 *      .event.spi.PostLoadEvent)
 */
@Override
public void onPostLoad(PostLoadEvent event) {
    execute(postLoad, event.getEntity());
}
项目:jooby    文件:HbmEventListenerFeature.java   
@Override
public void onPostLoad(final PostLoadEvent event) {
  Member member = (Member) event.getEntity();
  member.setAlias(service.alias());
}
项目:jooby    文件:BeerLoaded.java   
@Override
public void onPostLoad(final PostLoadEvent event) {
  System.out.println(System.identityHashCode(this));
  System.out.println(event);
}
项目:hibernate-examples    文件:PersistentObjectListener.java   
@Override
public void onPostLoad(PostLoadEvent event) {
    if (event.getEntity() instanceof PersistentObject) {
        ((PersistentObject) event.getEntity()).onLoad();
    }
}
项目:ix3    文件:EventListenerImplRuleEngine.java   
@Override
public void onPostLoad(PostLoadEvent ple) {
    autowired();
    EntityMode entityMode = ple.getPersister().getEntityMode();

    RuleContext ruleContext = new RuleContextImplNoPrincipal(ple.getEntity(), null);

    fireRules(ruleContext, ple.getPersister(), null, entityMode, RuleGroupPredefined.PostRead.class);

}