May be I am doing something wrong, but my interceptor is never getting called. Here is how I am using the Interceptor.
Code:
session = sessionFactory.openSession(new MyInterceptor());
and in MyInterceptor, I am overrriding the onflushDirty() method, here are the first few lines, that just test if this method is ever getting called when an object is modified:
Code:
public boolean onFlushDirty(Object entity, Serializable serialId, Object[] currentState, Object[] previousState, String[] propertyNames, Type[] types) throws CallbackException {
log.debug("onFlushDirty() method called");
System.out.println("onFlushDirty() method called");
.....
return false;
Here is my test code, where I modify a Hibernate generated object:
Code:
Opportunity opp = LeadServices.getOpportunityByObjid(new BigDecimal(268545434));
System.out.println("test_auditLog(): Name = " + opp.getName());
opp.setRank(new BigDecimal(400));
LeadServices.updateLead(opp);
As expected, Hibernate modifies the object and I can see the changes in database, but it looks like it never calls my interceptor's onFlushDirty() method (because it never prints the log/print statements I have at the beginning of that method).
Any help is highly appreciated.