Java Code Examples for org.hibernate.event.spi.EventType

The following are top voted examples for showing how to use org.hibernate.event.spi.EventType. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: lams   File: EntityUpdateAction.java   View source code 7 votes vote down vote up
private boolean preUpdate() {
	boolean veto = false;
	final EventListenerGroup<PreUpdateEventListener> listenerGroup = listenerGroup( EventType.PRE_UPDATE );
	if ( listenerGroup.isEmpty() ) {
		return veto;
	}
	final PreUpdateEvent event = new PreUpdateEvent(
			getInstance(),
			getId(),
			state,
			previousState,
			getPersister(),
			eventSource()
	);
	for ( PreUpdateEventListener listener : listenerGroup.listeners() ) {
		veto |= listener.onPreUpdate( event );
	}
	return veto;
}
 
Example 2
Project: lams   File: TwoPhaseLoad.java   View source code 6 votes vote down vote up
/**
 * 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 );
		}
	}
}
 
Example 3
Project: lams   File: SessionImpl.java   View source code 6 votes vote down vote up
@Override
public boolean isDirty() throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	LOG.debug( "Checking session dirtiness" );
	if ( actionQueue.areInsertionsOrDeletionsQueued() ) {
		LOG.debug( "Session dirty (scheduled updates and insertions)" );
		return true;
	}
	DirtyCheckEvent event = new DirtyCheckEvent( this );
	for ( DirtyCheckEventListener listener : listeners( EventType.DIRTY_CHECK ) ) {
		listener.onDirtyCheck( event );
	}
	delayedAfterCompletion();
	return event.isDirty();
}
 
Example 4
Project: lams   File: EventListenerGroupImpl.java   View source code 6 votes vote down vote up
public EventListenerGroupImpl(EventType<T> eventType) {
	this.eventType = eventType;
	duplicationStrategies.add(
			// At minimum make sure we do not register the same exact listener class multiple times.
			new DuplicationStrategy() {
				@Override
				public boolean areMatch(Object listener, Object original) {
					return listener.getClass().equals( original.getClass() );
				}

				@Override
				public Action getAction() {
					return Action.ERROR;
				}
			}
	);
}
 
Example 5
Project: lams   File: EventListenerRegistryImpl.java   View source code 6 votes vote down vote up
private static <T> void prepareListeners(EventType<T> type, T defaultListener, Map<EventType,EventListenerGroupImpl> map) {
	final EventListenerGroupImpl<T> listenerGroup;
	if ( type == EventType.POST_COMMIT_DELETE
			|| type == EventType.POST_COMMIT_INSERT
			|| type == EventType.POST_COMMIT_UPDATE ) {
		listenerGroup = new PostCommitEventListenerGroupImpl<T>( type );
	}
	else {
		listenerGroup = new EventListenerGroupImpl<T>( type );
	}

	if ( defaultListener != null ) {
		listenerGroup.appendListener( defaultListener );
	}
	map.put( type, listenerGroup  );
}
 
Example 6
Project: lams   File: PostCommitEventListenerGroupImpl.java   View source code 6 votes vote down vote up
public PostCommitEventListenerGroupImpl(EventType<T> eventType) {
	super( eventType );

	if ( eventType == EventType.POST_COMMIT_DELETE ) {
		this.extendedListenerContract = PostCommitDeleteEventListener.class;
	}
	else if ( eventType == EventType.POST_COMMIT_INSERT ) {
		this.extendedListenerContract = PostCommitInsertEventListener.class;
	}
	else if ( eventType == EventType.POST_COMMIT_UPDATE ) {
		this.extendedListenerContract = PostCommitUpdateEventListener.class;
	}
	else {
		throw new IllegalStateException( "Unexpected usage of PostCommitEventListenerGroupImpl" );
	}
}
 
Example 7
Project: lams   File: EntityDeleteAction.java   View source code 6 votes vote down vote up
private void postDelete() {
	final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_DELETE );
	if ( listenerGroup.isEmpty() ) {
		return;
	}
	final PostDeleteEvent event = new PostDeleteEvent(
			getInstance(),
			getId(),
			state,
			getPersister(),
			eventSource()
	);
	for ( PostDeleteEventListener listener : listenerGroup.listeners() ) {
		listener.onPostDelete( event );
	}
}
 
Example 8
Project: lams   File: EntityInsertAction.java   View source code 6 votes vote down vote up
private void postInsert() {
	final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup( EventType.POST_INSERT );
	if ( listenerGroup.isEmpty() ) {
		return;
	}
	final PostInsertEvent event = new PostInsertEvent(
			getInstance(),
			getId(),
			getState(),
			getPersister(),
			eventSource()
	);
	for ( PostInsertEventListener listener : listenerGroup.listeners() ) {
		listener.onPostInsert( event );
	}
}
 
Example 9
Project: lams   File: EntityIdentityInsertAction.java   View source code 6 votes vote down vote up
private void postInsert() {
	if ( isDelayed ) {
		getSession().getPersistenceContext().replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
	}

	final EventListenerGroup<PostInsertEventListener> listenerGroup = listenerGroup( EventType.POST_INSERT );
	if ( listenerGroup.isEmpty() ) {
		return;
	}
	final PostInsertEvent event = new PostInsertEvent(
			getInstance(),
			generatedId,
			getState(),
			getPersister(),
			eventSource()
	);
	for ( PostInsertEventListener listener : listenerGroup.listeners() ) {
		listener.onPostInsert( event );
	}
}
 
Example 10
Project: lams   File: EntityUpdateAction.java   View source code 6 votes vote down vote up
private void postUpdate() {
	final EventListenerGroup<PostUpdateEventListener> listenerGroup = listenerGroup( EventType.POST_UPDATE );
	if ( listenerGroup.isEmpty() ) {
		return;
	}
	final PostUpdateEvent event = new PostUpdateEvent(
			getInstance(),
			getId(),
			state,
			previousState,
			dirtyFields,
			getPersister(),
			eventSource()
	);
	for ( PostUpdateEventListener listener : listenerGroup.listeners() ) {
		listener.onPostUpdate( event );
	}
}
 
Example 11
Project: spring-data-rest-webhook   File: EventListenerRegistryAdapter.java   View source code 6 votes vote down vote up
@PostConstruct
public void registerListeners() {
    // TODO: This method of getting a reference to the SessionFactory (and thereforce the ServiceRegistry) is Deprecated. Find out the right Hibernate 5.2 way to do this.
    EventListenerRegistry registry = entityManagerFactory.getSessionFactory().getServiceRegistry().getService(EventListenerRegistry.class);
    if (preInsertEventListeners != null) {
        registry.appendListeners(EventType.PRE_INSERT, preInsertEventListeners.toArray(new PreInsertEventListener[preInsertEventListeners.size()]));
    }
    if (postInsertEventListeners != null) {
        registry.appendListeners(EventType.POST_INSERT, postInsertEventListeners.toArray(new PostInsertEventListener[postInsertEventListeners.size()]));
    }
    if (preUpdateEventListeners != null) {
        registry.appendListeners(EventType.PRE_UPDATE, preUpdateEventListeners.toArray(new PreUpdateEventListener[preUpdateEventListeners.size()]));
    }
    if (postUpdateEventListeners != null) {
        registry.appendListeners(EventType.POST_UPDATE, postUpdateEventListeners.toArray(new PostUpdateEventListener[postUpdateEventListeners.size()]));
    }
    if (preDeleteEventListeners != null) {
        registry.appendListeners(EventType.PRE_DELETE, preDeleteEventListeners.toArray(new PreDeleteEventListener[preDeleteEventListeners.size()]));
    }
    if (postDeleteEventListeners != null) {
        registry.appendListeners(EventType.POST_DELETE, postDeleteEventListeners.toArray(new PostDeleteEventListener[postDeleteEventListeners.size()]));
    }
}
 
Example 12
Project: ipf-flow-manager   File: CustomEventRegistration.java   View source code 6 votes vote down vote up
@Override
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
    EventListenerRegistry service = serviceRegistry.getService(org.hibernate.event.service.spi.EventListenerRegistry.class);

    StandardPBEStringEncryptor encrypt = new StandardPBEStringEncryptor();
    encrypt.setPassword("test_password");
    RenderedMessageEncryptEventListener encryptListener = new RenderedMessageEncryptEventListener();
    encryptListener.setStringEncryptor(encrypt);

    RenderedMessageDecryptEventListener decryptListener = new RenderedMessageDecryptEventListener();
    decryptListener.setStringEncryptor(encrypt);

    FullTextIndexEventListener fullTextListener = new FullTextIndexEventListener();

    service.appendListeners(EventType.PRE_UPDATE, encryptListener);
    service.prependListeners(EventType.POST_UPDATE, decryptListener);
    service.appendListeners(EventType.PRE_INSERT, encryptListener);
    service.prependListeners(EventType.POST_INSERT, decryptListener);
    service.appendListeners(EventType.POST_LOAD, decryptListener);
}
 
Example 13
Project: Audit4j-Hibernate   File: Audit4jIntegrator.java   View source code 6 votes vote down vote up
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory,
        SessionFactoryServiceRegistry serviceRegistry) {
    System.out.println("Integrating......");

    //final AuditService auditService = serviceRegistry.getService(AuditService.class);
    final AuditService auditService = new AuditServiceImpl();
    auditService.init();
    if (!auditService.isInitialized()) {
        throw new InitializationException(
                "Audit4j hibernate integration can not be initialized..");
    }

    // Register listeners..
    final EventListenerRegistry listenerRegistry = serviceRegistry
            .getService(EventListenerRegistry.class);

    listenerRegistry.appendListeners(EventType.POST_INSERT,
            new AuditPostInsertEventListenerImpl(auditService));
    listenerRegistry.appendListeners(EventType.POST_UPDATE,
            new AuditPostUpdateEventListenerImpl(auditService));
    listenerRegistry.appendListeners(EventType.POST_DELETE,
            new AuditPostDeleteEventListenerImpl(auditService));
}
 
Example 14
Project: gorm-hibernate5   File: EventListenerIntegrator.java   View source code 6 votes vote down vote up
protected <T> void appendListeners(EventListenerRegistry listenerRegistry,
                                   EventType<T> eventType, Collection<T> listeners) {

    EventListenerGroup<T> group = listenerRegistry.getEventListenerGroup(eventType);
    for (T listener : listeners) {
        if (listener != null) {
            if(shouldOverrideListeners(eventType, listener)) {
                // since ClosureEventTriggeringInterceptor extends DefaultSaveOrUpdateEventListener we want to override instead of append the listener here
                // to avoid there being 2 implementations which would impact performance too
                group.clear();
                group.appendListener(listener);
            }
            else {
                group.appendListener(listener);
            }
        }
    }
}
 
Example 15
Project: gorm-hibernate5   File: EventListenerIntegrator.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected <T> void appendListeners(final EventListenerRegistry listenerRegistry,
                                   final EventType<T> eventType, final Map<String, Object> listeners) {

    Object listener = listeners.get(eventType.eventName());
    if (listener != null) {
        if(shouldOverrideListeners(eventType, listener)) {
            // since ClosureEventTriggeringInterceptor extends DefaultSaveOrUpdateEventListener we want to override instead of append the listener here
            // to avoid there being 2 implementations which would impact performance too
            listenerRegistry.setListeners(eventType, (T) listener);
        }
        else {
            listenerRegistry.appendListeners(eventType, (T)listener);
        }
    }
}
 
Example 16
Project: windup-rulesets   File: MyIntegrator.java   View source code 6 votes vote down vote up
@Override
public void integrate(org.hibernate.cfg.Configuration configuration,
            org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory,
            org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry) 
{
        
    
    final EventListenerRegistry eventRegistry =
        serviceRegistry.getService(EventListenerRegistry.class);

    eventRegistry.prependListeners(EventType.POST_COMMIT_INSERT, listener);
    
    final AuditConfiguration enversConfiguration = AuditConfiguration.getFor( configuration );
    AuditStrategy auditStrategy = enversConfiguration.getAuditStrategy();

    if (enversConfiguration.getEntCfg().hasAuditedEntities()) {
        listenerRegistry.appendListeners( EventType.POST_DELETE, new EnversPostDeleteEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_INSERT, new EnversPostInsertEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_UPDATE, new EnversPostUpdateEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.POST_COLLECTION_RECREATE, new EnversPostCollectionRecreateEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.PRE_COLLECTION_REMOVE, new EnversPreCollectionRemoveEventListenerImpl( enversConfiguration ) );
        listenerRegistry.appendListeners( EventType.PRE_COLLECTION_UPDATE, new EnversPreCollectionUpdateEventListenerImpl( enversConfiguration ) );
    }
    
}
 
Example 17
Project: debop4j   File: HibernateTool.java   View source code 6 votes vote down vote up
/**
 * Register event listener.
 *
 * @param sessionFactory the session factory
 * @param listener       the listener
 * @param eventTypes     the event types
 */
@SuppressWarnings("unchecked")
public static void registerEventListener(SessionFactory sessionFactory, Object listener, EventType... eventTypes) {
    shouldNotBeNull(sessionFactory, "sessionFactory");
    shouldNotBeNull(listener, "listener");


        log.trace("sessionFactory에 event listener를 등록합니다... listener=[{}], eventTypes=[{}]",
                  listener, StringTool.listToString(eventTypes));

    EventListenerRegistry registry =
            ((SessionFactoryImpl) sessionFactory)
                    .getServiceRegistry()
                    .getService(EventListenerRegistry.class);

    for (EventType eventType : eventTypes) {
        try {
            registry.getEventListenerGroup(eventType).appendListener(listener);
        } catch (Exception ignored) {}
    }

}
 
Example 18
Project: lams   File: TypeSafeActivator.java   View source code 5 votes vote down vote up
@SuppressWarnings( {"UnusedDeclaration"})
public static void applyCallbackListeners(ValidatorFactory validatorFactory, ActivationContext activationContext) {
	final Set<ValidationMode> modes = activationContext.getValidationModes();
	if ( ! ( modes.contains( ValidationMode.CALLBACK ) || modes.contains( ValidationMode.AUTO ) ) ) {
		return;
	}

	// de-activate not-null tracking at the core level when Bean Validation is present unless the user explicitly
	// asks for it
	if ( activationContext.getConfiguration().getProperty( Environment.CHECK_NULLABILITY ) == null ) {
		activationContext.getSessionFactory().getSettings().setCheckNullability( false );
	}

	final BeanValidationEventListener listener = new BeanValidationEventListener(
			validatorFactory,
			activationContext.getConfiguration().getProperties()
	);

	final EventListenerRegistry listenerRegistry = activationContext.getServiceRegistry()
			.getService( EventListenerRegistry.class );

	listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );

	listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
	listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
	listenerRegistry.appendListeners( EventType.PRE_DELETE, listener );

	listener.initialize( activationContext.getConfiguration() );
}
 
Example 19
Project: lams   File: AbstractEntityTuplizer.java   View source code 5 votes vote down vote up
private static Iterable<PersistEventListener> persistEventListeners(SessionImplementor session) {
	return session
			.getFactory()
			.getServiceRegistry()
			.getService( EventListenerRegistry.class )
			.getEventListenerGroup( EventType.PERSIST )
			.listeners();
}
 
Example 20
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void internalClear() {
	persistenceContext.clear();
	actionQueue.clear();

	final ClearEvent event = new ClearEvent( this );
	for ( ClearEventListener listener : listeners( EventType.CLEAR ) ) {
		listener.onClear( event );
	}
}
 
Example 21
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireSaveOrUpdate(SaveOrUpdateEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( SaveOrUpdateEventListener listener : listeners( EventType.SAVE_UPDATE ) ) {
		listener.onSaveOrUpdate( event );
	}
	checkNoUnresolvedActionsAfterOperation();
}
 
Example 22
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private Serializable fireSave(SaveOrUpdateEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( SaveOrUpdateEventListener listener : listeners( EventType.SAVE ) ) {
		listener.onSaveOrUpdate( event );
	}
	checkNoUnresolvedActionsAfterOperation();
	return event.getResultId();
}
 
Example 23
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireUpdate(SaveOrUpdateEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( SaveOrUpdateEventListener listener : listeners( EventType.UPDATE ) ) {
		listener.onSaveOrUpdate( event );
	}
	checkNoUnresolvedActionsAfterOperation();
}
 
Example 24
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireLock(LockEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( LockEventListener listener : listeners( EventType.LOCK ) ) {
		listener.onLock( event );
	}
	delayedAfterCompletion();
}
 
Example 25
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void firePersist(Map copiedAlready, PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) {
		listener.onPersist( event, copiedAlready );
	}
	delayedAfterCompletion();
}
 
Example 26
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void firePersist(PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( PersistEventListener listener : listeners( EventType.PERSIST ) ) {
		listener.onPersist( event );
	}
	checkNoUnresolvedActionsAfterOperation();
}
 
Example 27
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void firePersistOnFlush(Map copiedAlready, PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( PersistEventListener listener : listeners( EventType.PERSIST_ONFLUSH ) ) {
		listener.onPersist( event, copiedAlready );
	}
	delayedAfterCompletion();
}
 
Example 28
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void firePersistOnFlush(PersistEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( PersistEventListener listener : listeners( EventType.PERSIST_ONFLUSH ) ) {
		listener.onPersist( event );
	}
	checkNoUnresolvedActionsAfterOperation();
}
 
Example 29
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private Object fireMerge(MergeEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	checkNoUnresolvedActionsBeforeOperation();
	for ( MergeEventListener listener : listeners( EventType.MERGE ) ) {
		listener.onMerge( event );
	}
	checkNoUnresolvedActionsAfterOperation();
	return event.getResult();
}
 
Example 30
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireMerge(Map copiedAlready, MergeEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( MergeEventListener listener : listeners( EventType.MERGE ) ) {
		listener.onMerge( event, copiedAlready );
	}
	delayedAfterCompletion();
}
 
Example 31
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireDelete(DeleteEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
		listener.onDelete( event );
	}
	delayedAfterCompletion();
}
 
Example 32
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireDelete(DeleteEvent event, Set transientEntities) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( DeleteEventListener listener : listeners( EventType.DELETE ) ) {
		listener.onDelete( event, transientEntities );
	}
	delayedAfterCompletion();
}
 
Example 33
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireLoad(LoadEvent event, LoadType loadType) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( LoadEventListener listener : listeners( EventType.LOAD ) ) {
		listener.onLoad( event, loadType );
	}
	delayedAfterCompletion();
}
 
Example 34
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireResolveNaturalId(ResolveNaturalIdEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( ResolveNaturalIdEventListener listener : listeners( EventType.RESOLVE_NATURAL_ID ) ) {
		listener.onResolveNaturalId( event );
	}
	delayedAfterCompletion();
}
 
Example 35
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireRefresh(RefreshEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( RefreshEventListener listener : listeners( EventType.REFRESH ) ) {
		listener.onRefresh( event );
	}
	delayedAfterCompletion();
}
 
Example 36
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireRefresh(Map refreshedAlready, RefreshEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( RefreshEventListener listener : listeners( EventType.REFRESH ) ) {
		listener.onRefresh( event, refreshedAlready );
	}
	delayedAfterCompletion();
}
 
Example 37
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireReplicate(ReplicateEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( ReplicateEventListener listener : listeners( EventType.REPLICATE ) ) {
		listener.onReplicate( event );
	}
	delayedAfterCompletion();
}
 
Example 38
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
private void fireEvict(EvictEvent event) {
	errorIfClosed();
	checkTransactionSynchStatus();
	for ( EvictEventListener listener : listeners( EventType.EVICT ) ) {
		listener.onEvict( event );
	}
	delayedAfterCompletion();
}
 
Example 39
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
/**
 * detect in-memory changes, determine if the changes are to tables
 * named in the query and, if so, complete execution the flush
 */
protected boolean autoFlushIfRequired(Set querySpaces) throws HibernateException {
	errorIfClosed();
	if ( ! isTransactionInProgress() ) {
		// do not auto-flush while outside a transaction
		return false;
	}
	AutoFlushEvent event = new AutoFlushEvent( querySpaces, this );
	for ( AutoFlushEventListener listener : listeners( EventType.AUTO_FLUSH ) ) {
		listener.onAutoFlush( event );
	}
	return event.isFlushRequired();
}
 
Example 40
Project: lams   File: SessionImpl.java   View source code 5 votes vote down vote up
@Override
public void flush() throws HibernateException {
	errorIfClosed();
	checkTransactionSynchStatus();
	if ( persistenceContext.getCascadeLevel() > 0 ) {
		throw new HibernateException("Flush during cascade is dangerous");
	}
	FlushEvent flushEvent = new FlushEvent( this );
	for ( FlushEventListener listener : listeners( EventType.FLUSH ) ) {
		listener.onFlush( flushEvent );
	}
	delayedAfterCompletion();
}