afterTransactionCompletion not working
Posted
by Attilah
on Stack Overflow
See other posts from Stack Overflow
or by Attilah
Published on 2009-11-11T07:59:45Z
Indexed on
2010/05/10
13:04 UTC
Read the original article
Hit count: 183
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 ?
© Stack Overflow or respective owner