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

项目: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    文件:DefaultLoadEventListener.java   
private Iterable<PostLoadEventListener> postLoadEventListeners(EventSource session) {
    return session
            .getFactory()
            .getServiceRegistry()
            .getService( EventListenerRegistry.class )
            .getEventListenerGroup( EventType.POST_LOAD )
            .listeners();
}