Example usage for org.hibernate.event.spi PostCollectionRecreateEvent getAffectedOwnerIdOrNull

List of usage examples for org.hibernate.event.spi PostCollectionRecreateEvent getAffectedOwnerIdOrNull

Introduction

In this page you can find the example usage for org.hibernate.event.spi PostCollectionRecreateEvent getAffectedOwnerIdOrNull.

Prototype

public Serializable getAffectedOwnerIdOrNull() 

Source Link

Document

Get the ID for the collection owner entity that is affected by this event.

Usage

From source file:com.googlecode.hibernate.audit.listener.AuditListener.java

License:Open Source License

public void onPostRecreateCollection(PostCollectionRecreateEvent event) {
    try {/*from  www.j av  a  2  s . c o  m*/
        String entityName = event.getAffectedOwnerEntityName();

        if (auditConfiguration.getExtensionManager().getAuditableInformationProvider().isAuditable(entityName)
                && (recordEmptyCollectionsOnInsert || !event.getCollection().empty())) {
            AuditProcess auditProcess = auditConfiguration.getAuditProcessManager().get(event.getSession());
            AuditWorkUnit workUnit = new InsertCollectionAuditWorkUnit(entityName,
                    event.getAffectedOwnerIdOrNull(), event.getAffectedOwnerOrNull(), event.getCollection());
            auditProcess.addWorkUnit(workUnit);
        }
    } catch (RuntimeException e) {
        if (log.isErrorEnabled()) {
            log.error("RuntimeException occured during onPostRecreateCollection, will re-throw the exception",
                    e);
        }
        throw e;
    }
}