use of org.hibernate.reactive.session.ReactiveSession in project hibernate-reactive by hibernate.
the class Cascade method deleteOrphans.
/**
* Delete any entities that were removed from the collection
*/
private void deleteOrphans(String entityName, PersistentCollection pc) throws HibernateException {
// TODO: suck this logic into the collection!
final Collection<?> orphans;
if (pc.wasInitialized()) {
final CollectionEntry ce = eventSource.getPersistenceContextInternal().getCollectionEntry(pc);
if (ce == null) {
return;
}
orphans = ce.getOrphans(entityName, pc);
} else {
orphans = pc.getQueuedOrphans(entityName);
}
ReactiveSession session = (ReactiveSession) eventSource;
stage = stage.thenCompose(v -> loop(orphans, Objects::nonNull, orphan -> {
LOG.tracev("Deleting orphaned entity instance: {0}", entityName);
return session.reactiveRemove(orphan, false, new IdentitySet());
}));
}
Aggregations