use of org.hibernate.envers.internal.synchronization.AuditProcess in project hibernate-orm by hibernate.
the class EnversPostInsertEventListenerImpl method onPostInsert.
@Override
public void onPostInsert(PostInsertEvent event) {
final String entityName = event.getPersister().getEntityName();
if (getEnversService().getEntitiesConfigurations().isVersioned(entityName)) {
checkIfTransactionInProgress(event.getSession());
final AuditProcess auditProcess = getEnversService().getAuditProcessManager().get(event.getSession());
final AuditWorkUnit workUnit = new AddWorkUnit(event.getSession(), event.getPersister().getEntityName(), getEnversService(), event.getId(), event.getPersister(), event.getState());
auditProcess.addWorkUnit(workUnit);
if (workUnit.containsWork()) {
generateBidirectionalCollectionChangeWorkUnits(auditProcess, event.getPersister(), entityName, event.getState(), null, event.getSession());
}
}
}
use of org.hibernate.envers.internal.synchronization.AuditProcess in project hibernate-orm by hibernate.
the class EnversPostUpdateEventListenerImpl method onPostUpdate.
@Override
public void onPostUpdate(PostUpdateEvent event) {
final String entityName = event.getPersister().getEntityName();
if (getEnversService().getEntitiesConfigurations().isVersioned(entityName)) {
checkIfTransactionInProgress(event.getSession());
final AuditProcess auditProcess = getEnversService().getAuditProcessManager().get(event.getSession());
Object[] oldState = getOldDBState(auditProcess, entityName, event);
final Object[] newDbState = postUpdateDBState(event);
final AuditWorkUnit workUnit = new ModWorkUnit(event.getSession(), event.getPersister().getEntityName(), getEnversService(), event.getId(), event.getPersister(), newDbState, oldState);
auditProcess.addWorkUnit(workUnit);
if (workUnit.containsWork()) {
generateBidirectionalCollectionChangeWorkUnits(auditProcess, event.getPersister(), entityName, newDbState, oldState, event.getSession());
}
}
}
use of org.hibernate.envers.internal.synchronization.AuditProcess in project hibernate-orm by hibernate.
the class AuditReaderImpl method getCurrentRevision.
@Override
@SuppressWarnings({ "unchecked" })
public <T> T getCurrentRevision(Class<T> revisionEntityClass, boolean persist) {
revisionEntityClass = getTargetClassIfProxied(revisionEntityClass);
if (!(session instanceof EventSource)) {
throw new IllegalArgumentException("The provided session is not an EventSource!");
}
// Obtaining the current audit sync
final AuditProcess auditProcess = enversService.getAuditProcessManager().get((EventSource) session);
// And getting the current revision data
return (T) auditProcess.getCurrentRevisionData(session, persist);
}
use of org.hibernate.envers.internal.synchronization.AuditProcess in project hibernate-orm by hibernate.
the class EnversPostDeleteEventListenerImpl method onPostDelete.
@Override
public void onPostDelete(PostDeleteEvent event) {
final String entityName = event.getPersister().getEntityName();
if (getEnversService().getEntitiesConfigurations().isVersioned(entityName)) {
checkIfTransactionInProgress(event.getSession());
final AuditProcess auditProcess = getEnversService().getAuditProcessManager().get(event.getSession());
final AuditWorkUnit workUnit = new DelWorkUnit(event.getSession(), event.getPersister().getEntityName(), getEnversService(), event.getId(), event.getPersister(), event.getDeletedState());
auditProcess.addWorkUnit(workUnit);
if (workUnit.containsWork()) {
generateBidirectionalCollectionChangeWorkUnits(auditProcess, event.getPersister(), entityName, null, event.getDeletedState(), event.getSession());
}
}
}
use of org.hibernate.envers.internal.synchronization.AuditProcess in project hibernate-orm by hibernate.
the class EnversPreUpdateEventListenerImpl method onPreUpdate.
@Override
public boolean onPreUpdate(PreUpdateEvent event) {
final String entityName = event.getPersister().getEntityName();
if (getEnversService().getEntitiesConfigurations().isVersioned(entityName)) {
checkIfTransactionInProgress(event.getSession());
if (isDetachedEntityUpdate(entityName, event.getOldState())) {
final AuditProcess auditProcess = getEnversService().getAuditProcessManager().get(event.getSession());
auditProcess.cacheEntityState(event.getId(), entityName, event.getPersister().getDatabaseSnapshot(event.getId(), event.getSession()));
}
}
return false;
}
Aggregations