java后转换完成不工作
我创建了一个hibernate拦截器:
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.");
}
}
}
但是TransactionCompletion方法不会在提交事务后执行。我已经尝试了所有我知道的方法,但我不能让它工作。更令人惊讶的是,onSave方法工作得很好
救命
Could this be due to this bug ? :
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1956
如果这是原因,我该如何避开这个漏洞
# 1 楼答案
后交易完成的标志应该是什么?在我找到的文件中,它说:
在这种情况下,不调用您的方法也就不足为奇了
我认为如果你使用@Override注释,编译器会警告你签名错误