use of org.hibernate.event.spi.MergeEvent in project hibernate-reactive by hibernate.
the class DefaultReactiveMergeEventListener method reactiveOnMerge.
/**
* Handle the given merge event.
*
* @param event The merge event to be handled.
*/
@Override
public CompletionStage<Void> reactiveOnMerge(MergeEvent event) throws HibernateException {
final EntityCopyObserver entityCopyObserver = createEntityCopyObserver(event.getSession().getFactory());
final MergeContext mergeContext = new MergeContext(event.getSession(), entityCopyObserver);
return reactiveOnMerge(event, mergeContext).thenAccept(v -> entityCopyObserver.topLevelMergeComplete(event.getSession())).whenComplete((v, e) -> {
entityCopyObserver.clear();
mergeContext.clear();
});
}
use of org.hibernate.event.spi.MergeEvent in project hibernate-reactive by hibernate.
the class DefaultReactiveMergeEventListener method entityIsPersistent.
protected CompletionStage<Void> entityIsPersistent(MergeEvent event, MergeContext copyCache) {
LOG.trace("Ignoring persistent instance");
// TODO: check that entry.getIdentifier().equals(requestedId)
final Object entity = event.getEntity();
final EventSource source = event.getSession();
final EntityPersister persister = source.getEntityPersister(event.getEntityName(), entity);
// before cascade!
copyCache.put(entity, entity, true);
return cascadeOnMerge(source, persister, entity, copyCache).thenCompose(v -> fetchAndCopyValues(persister, entity, entity, source, copyCache)).thenAccept(v -> event.setResult(entity));
}
use of org.hibernate.event.spi.MergeEvent in project BridgeServer2 by Sage-Bionetworks.
the class TagEventListenerTest method onMerge.
@Test
public void onMerge() throws HibernateException {
MergeEvent event = new MergeEvent(new Tag("value"), null);
event.setEntity(new Tag("value"));
listener.onMerge(event);
verify(cacheProvider).removeObject(CacheKey.tagList());
}
use of org.hibernate.event.spi.MergeEvent in project BridgeServer2 by Sage-Bionetworks.
the class TagEventListenerTest method onMergeWithCopiedAlreadyNotTag.
@Test
public void onMergeWithCopiedAlreadyNotTag() throws HibernateException {
MergeEvent event = new MergeEvent(new HibernateAssessment(), null);
event.setEntity(new HibernateAssessment());
listener.onMerge(event, null);
verify(cacheProvider, never()).removeObject(CacheKey.tagList());
}
use of org.hibernate.event.spi.MergeEvent in project BridgeServer2 by Sage-Bionetworks.
the class TagEventListenerTest method onMergeNotTag.
@Test
public void onMergeNotTag() throws HibernateException {
MergeEvent event = new MergeEvent(new HibernateAssessment(), null);
event.setEntity(new HibernateAssessment());
listener.onMerge(event);
verify(cacheProvider, never()).removeObject(CacheKey.tagList());
}
Aggregations