Search in sources :

Example 1 with DeleteEvent

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

the class SessionImpl method delete.

@Override
@Deprecated
public void delete(String entityName, Object object) throws HibernateException {
    checkOpen();
    fireDelete(new DeleteEvent(entityName, object, this));
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent)

Example 2 with DeleteEvent

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

the class SessionImpl method delete.

@Override
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) throws HibernateException {
    checkOpenOrWaitingForAutoClose();
    final boolean removingOrphanBeforeUpates = persistenceContext.isRemovingOrphanBeforeUpates();
    final boolean traceEnabled = log.isTraceEnabled();
    if (traceEnabled && removingOrphanBeforeUpates) {
        logRemoveOrphanBeforeUpdates("before continuing", entityName, object);
    }
    fireDelete(new DeleteEvent(entityName, object, isCascadeDeleteEnabled, removingOrphanBeforeUpates, this), transientEntities);
    if (traceEnabled && removingOrphanBeforeUpates) {
        logRemoveOrphanBeforeUpdates("after continuing", entityName, object);
    }
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent)

Example 3 with DeleteEvent

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

the class SessionImpl method removeOrphanBeforeUpdates.

@Override
public void removeOrphanBeforeUpdates(String entityName, Object child) {
    // TODO: The removeOrphan concept is a temporary "hack" for HHH-6484.  This should be removed once action/task
    // ordering is improved.
    final boolean traceEnabled = log.isTraceEnabled();
    if (traceEnabled) {
        logRemoveOrphanBeforeUpdates("begin", entityName, child);
    }
    persistenceContext.beginRemoveOrphanBeforeUpdates();
    try {
        checkOpenOrWaitingForAutoClose();
        fireDelete(new DeleteEvent(entityName, child, false, true, this));
    } finally {
        persistenceContext.endRemoveOrphanBeforeUpdates();
        if (traceEnabled) {
            logRemoveOrphanBeforeUpdates("end", entityName, child);
        }
    }
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent)

Example 4 with DeleteEvent

use of org.hibernate.event.spi.DeleteEvent in project hibernate-reactive by hibernate.

the class ReactiveSessionImpl method reactiveRemoveOrphanBeforeUpdates.

@Override
public CompletionStage<Void> reactiveRemoveOrphanBeforeUpdates(String entityName, Object child) {
    // TODO: The removeOrphan concept is a temporary "hack" for HHH-6484.  This should be removed once action/task
    // ordering is improved.
    final StatefulPersistenceContext persistenceContext = (StatefulPersistenceContext) getPersistenceContextInternal();
    persistenceContext.beginRemoveOrphanBeforeUpdates();
    return fireRemove(new DeleteEvent(entityName, child, false, true, this)).thenAccept(v -> {
        persistenceContext.endRemoveOrphanBeforeUpdates();
        if (log.isTraceEnabled()) {
            logRemoveOrphanBeforeUpdates("end", entityName, child, persistenceContext);
        }
    });
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent) StatefulPersistenceContext(org.hibernate.engine.internal.StatefulPersistenceContext)

Example 5 with DeleteEvent

use of org.hibernate.event.spi.DeleteEvent in project BridgeServer2 by Sage-Bionetworks.

the class TagEventListenerTest method onDeleteWithTransientEntities.

@Test
public void onDeleteWithTransientEntities() throws HibernateException {
    DeleteEvent event = new DeleteEvent(new Tag("value"), null);
    listener.onDelete(event, null);
    verify(cacheProvider).removeObject(CacheKey.tagList());
}
Also used : DeleteEvent(org.hibernate.event.spi.DeleteEvent) Tag(org.sagebionetworks.bridge.models.Tag) Test(org.testng.annotations.Test)

Aggregations

DeleteEvent (org.hibernate.event.spi.DeleteEvent)10 Test (org.testng.annotations.Test)4 Tag (org.sagebionetworks.bridge.models.Tag)2 HibernateAssessment (org.sagebionetworks.bridge.models.assessments.HibernateAssessment)2 StatefulPersistenceContext (org.hibernate.engine.internal.StatefulPersistenceContext)1