Example usage for org.hibernate.event.spi PostInsertEvent getId

List of usage examples for org.hibernate.event.spi PostInsertEvent getId

Introduction

In this page you can find the example usage for org.hibernate.event.spi PostInsertEvent getId.

Prototype

public Serializable getId() 

Source Link

Usage

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

License:Open Source License

public void onPostInsert(PostInsertEvent event) {
    try {/*  ww  w  .  jav a 2 s  . c  om*/
        String entityName = event.getPersister().getEntityName();

        if (auditConfiguration.getExtensionManager().getAuditableInformationProvider()
                .isAuditable(entityName)) {
            AuditProcess auditProcess = auditConfiguration.getAuditProcessManager().get(event.getSession());

            AuditWorkUnit workUnit = new InsertAuditWorkUnit(entityName, event.getId(), event.getEntity(),
                    event.getPersister());
            auditProcess.addWorkUnit(workUnit);
        }
    } catch (RuntimeException e) {
        if (log.isErrorEnabled()) {
            log.error("RuntimeException occured during onPostInsert, will re-throw the exception", e);
        }
        throw e;
    }
}