Example usage for org.hibernate.event.spi PreCollectionRemoveEvent getCollection

List of usage examples for org.hibernate.event.spi PreCollectionRemoveEvent getCollection

Introduction

In this page you can find the example usage for org.hibernate.event.spi PreCollectionRemoveEvent getCollection.

Prototype

public PersistentCollection getCollection() 

Source Link

Usage

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

License:Open Source License

public void onPreRemoveCollection(PreCollectionRemoveEvent event) {
    try {//from   ww w . ja v  a  2  s.  co m
        String entityName = event.getAffectedOwnerEntityName();

        if (auditConfiguration.getExtensionManager().getAuditableInformationProvider()
                .isAuditable(entityName)) {
            AuditProcess auditProcess = auditConfiguration.getAuditProcessManager().get(event.getSession());
            AuditWorkUnit workUnit = new RemoveCollectionAuditWorkUnit(entityName,
                    event.getAffectedOwnerIdOrNull(), event.getAffectedOwnerOrNull(), event.getCollection());

            auditProcess.addWorkUnit(workUnit);
        }
    } catch (RuntimeException e) {
        if (log.isErrorEnabled()) {
            log.error("RuntimeException occured during onPreRemoveCollection, will re-throw the exception", e);
        }
        throw e;
    }
}