首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Spring与JDBC调整、事务处理

2012-11-03 
Spring与JDBC整合、事务处理Spring的配置文件public class PersonServiceBean implements PersonService {@

Spring与JDBC整合、事务处理

Spring的配置文件

public class PersonServiceBean implements PersonService {    @Resource Private OtherService otherService ;@Transactional    public void xxx(){    stmt.executeUpdate("update person set name='888' whereid=1");    otherService.update();//OtherService的update方法的事务传播属性为NESTED    stmt.executeUpdate("delete from person where id=9");      }} 

NESTED是一个比较特殊的属性,可以理解为事务的嵌套,就如上面的xxx方法是使用了事务的,也就是说一整个方法体属于一个事务,但是因为otherService.update被nested属性修饰了所以当这个方法出现异常而,其他操作没有出现异常的话,整个事务也会提交,除了otherService.update的事务不被提交

热点排行