Hi
i have a contention issue with an app. The solution is to re-write how we use the audit info and when. however, for a quick patch fix, I was wondering if I can force when a Interceptor fires or when not.
I have
Code:
public class AuditInterceptor extends EmptyInterceptor implements Interceptor, Serializable {
// some stuff
public boolean onSave(
Object entity,
Serializable id,
Object[] state,
String[] propertyNames,
Type[] types) {
//impl
}
}
This gets called all over the place but, on very rare occasions, it gets called in the session's commit() and this can cause a block in the DB. Without doing into details we end up frozen in a loop tween DB block and Java lock().
So, clearly, bad design but until fully sorted is there a way to force the commit to rollback if the Interceptor fires during commit() (now the weird thing is that the interceptor is only updating the audit information (and optimistic lock count) on the entity already being modified in the transaction)? Or force the interceptor to fire int he preparetocommit() only?
Apologies if this is old news or daft question but trying to get to grips with Hibernate innards here :)
Hib 3.2.5, Java 5 and Spring
Simon