I dont think that hibernate provide direct method to find dirty objects, however you may do this by extending EmptyInterceptor. something like this.
public class myAuditLogInterceptor extends EmptyInterceptor{ private Set dirtyAuditables = new HashSet(); public boolean onFlushDirty(Object entity, Serializable id, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException { dirtyAuditables .add(entity); return false; }
}
the size of the dirtyAuditable will tell you the no of dirty objects that are found in a particular session.
|