知道spring中的aop事务和日志的处理请进
我使用了spring2.5的aop处理事务,是使用注解的方式处理的,代码如下:
---------------------------------------------------------------
@Transactional(rollbackFor = Exception.class)
public void receiveVpAreasDatas(List<Area> areaList,List<ViewPoint> vpList,List<Mp3> mp3List){
if(areaList != null){
this.receiveAreaDatas(areaList);
}
if(vpList != null){
this.receiveVpDatas(vpList);
}
if(mp3List != null){
this.receiveMp3Datas(mp3List);
}
}
---------------------------------------------------------------
我对上面的代码进行了测试,如果receiveAreaDatas、receiveVpDatas
receiveMp3Datas中,无论哪个方法抛出了异常的话,事务都是可以回滚的。
是没有任何问题的。
但是如果服务器上代码有抛出异常的话,我想
把这些异常信息写入日志,方便以后查询,代码如下:
-----------------------------------------------------------------
@Transactional(rollbackFor = Exception.class)
public void receiveVpAreasDatas(List<Area> areaList,List<ViewPoint> vpList,List<Mp3> mp3List){
try{
if(areaList != null){
this.receiveAreaDatas(areaList);
}
if(vpList != null){
this.receiveVpDatas(vpList);
}
if(mp3List != null){
this.receiveMp3Datas(mp3List);
}
}catch(Exception e){
logger.debug("出错!");
}
}
-----------------------------------------------------------------
加入了异常处理后,我发现事务无法回滚了。
不知道是怎么回事。
请高手指教一下。