Search in sources :

Example 1 with PersistEventListener

use of org.hibernate.event.spi.PersistEventListener in project hibernate-orm by hibernate.

the class SessionImpl method firePersistOnFlush.

private void firePersistOnFlush(Map copiedAlready, PersistEvent event) {
    checkOpenOrWaitingForAutoClose();
    checkTransactionSynchStatus();
    for (PersistEventListener listener : listeners(EventType.PERSIST_ONFLUSH)) {
        listener.onPersist(event, copiedAlready);
    }
    delayedAfterCompletion();
}
Also used : PersistEventListener(org.hibernate.event.spi.PersistEventListener)

Example 2 with PersistEventListener

use of org.hibernate.event.spi.PersistEventListener in project hibernate-orm by hibernate.

the class SessionImpl method firePersist.

private void firePersist(PersistEvent event) {
    try {
        checkTransactionSynchStatus();
        checkNoUnresolvedActionsBeforeOperation();
        for (PersistEventListener listener : listeners(EventType.PERSIST)) {
            listener.onPersist(event);
        }
    } catch (MappingException e) {
        throw exceptionConverter.convert(new IllegalArgumentException(e.getMessage()));
    } catch (RuntimeException e) {
        throw exceptionConverter.convert(e);
    } finally {
        try {
            checkNoUnresolvedActionsAfterOperation();
        } catch (RuntimeException e) {
            throw exceptionConverter.convert(e);
        }
    }
}
Also used : PersistEventListener(org.hibernate.event.spi.PersistEventListener) UnknownSqlResultSetMappingException(org.hibernate.procedure.UnknownSqlResultSetMappingException) MappingException(org.hibernate.MappingException)

Example 3 with PersistEventListener

use of org.hibernate.event.spi.PersistEventListener in project hibernate-orm by hibernate.

the class AbstractEntityTuplizer method persistTransientEntity.

private static Serializable persistTransientEntity(Object entity, SharedSessionContractImplementor session) {
    assert session != null;
    LOG.debug("Performing implicit derived identity cascade");
    final PersistEvent event = new PersistEvent(null, entity, (EventSource) session);
    for (PersistEventListener listener : persistEventListeners(session)) {
        listener.onPersist(event);
    }
    final EntityEntry pcEntry = session.getPersistenceContext().getEntry(entity);
    if (pcEntry == null || pcEntry.getId() == null) {
        throw new HibernateException("Unable to process implicit derived identity cascade");
    }
    return pcEntry.getId();
}
Also used : PersistEventListener(org.hibernate.event.spi.PersistEventListener) EntityEntry(org.hibernate.engine.spi.EntityEntry) HibernateException(org.hibernate.HibernateException) PersistEvent(org.hibernate.event.spi.PersistEvent)

Example 4 with PersistEventListener

use of org.hibernate.event.spi.PersistEventListener in project hibernate-orm by hibernate.

the class SessionImpl method firePersistOnFlush.

private void firePersistOnFlush(PersistEvent event) {
    checkOpen();
    checkTransactionSynchStatus();
    checkNoUnresolvedActionsBeforeOperation();
    for (PersistEventListener listener : listeners(EventType.PERSIST_ONFLUSH)) {
        listener.onPersist(event);
    }
    checkNoUnresolvedActionsAfterOperation();
}
Also used : PersistEventListener(org.hibernate.event.spi.PersistEventListener)

Aggregations

PersistEventListener (org.hibernate.event.spi.PersistEventListener)4 HibernateException (org.hibernate.HibernateException)1 MappingException (org.hibernate.MappingException)1 EntityEntry (org.hibernate.engine.spi.EntityEntry)1 PersistEvent (org.hibernate.event.spi.PersistEvent)1 UnknownSqlResultSetMappingException (org.hibernate.procedure.UnknownSqlResultSetMappingException)1