afterTransactionCompletion not working
- by Attilah
I created an hibernate interceptor :
public class MyInterceptor extends EmptyInterceptor {
private boolean isCanal=false;
public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[] arg3, Type[] arg4) throws CallbackException {
for(int i=0;i<100;i++){
System.out.println("Inside MyInterceptor(onSave) : "+entity.toString());
}
if(entity instanceof Canal){
isCanal=true;
}
return false;
}
public void afterTransactionCompletion(Transaction tx){
if(tx.wasCommitted()&&(isCanal)){
for(int i=0;i<100;i++){
System.out.println("Inside MyInterceptor(afterTransactionCompletion) : Canal was saved to DB.");
}
}
}
but the method afterTransactionCompletion doesn't get executed after a transaction is commited. I've tried all the ways I know of but I can't make it work. What's more surprising is that the onSave method works fine.
Help !
Could this be due to this bug ? :
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1956
How can I circumvent this bug if it's the cause ?