String[] propertyNames,
Type[] types)
throws CallbackException {
if (entity instanceof Auditable) {
try {
Auditable auditable = (Auditable) entity;
if (!auditable.isSkipAudit()) {
// Use the id and class to get the pre-update state from the database
Session tempSession =
HibernateUtil.getSessionFactory().openSession();
Auditable old = (Auditable) tempSession.get(entity.getClass(), auditable.getId());
if (old == null)
return false; // old object is not yet persisted?
synchronized(oldies) {
oldies.put(old.getId(), old);
}
synchronized(updates) {
updates.add((Auditable)entity);
}
}