spring事务中插入的问题
现遇到这样一个问题
在ServiceAMethodA(){中
调用ServiceBMethodB();
try{
调用ServiceCMethodC();
}catch(Exception e){
throw new RuntimeException();
}
}
其中ServiceBMethodB()中向数据库中插入一条正确记录
ServiceCMethodC()中向数据库中插入一条字段超长的错误记录
经过下断点得到ServiceCMethodC()的异常并没有在ServiceCMethodC()执行后抛出,
而是在ServiceAMethodA()执行结束后抛出,所以try,catch中捕获不到异常
我把事务去掉后,执行ServiceCMethodC()方法后就会即时抛出异常,并捕获
我想是不是ServiceAMethodA()ServiceBMethodB()ServiceCMethodC()在一个事务中,
ServiceCMethodC()的插入(merge)方法没有提交到数据库中所致
如果这样的话,我想做事务处理应该怎么去配置,我是在service层设置事务的