疯狂

STANDING ON THE SHOULDERS OF GIANTS
posts - 481, comments - 486, trackbacks - 0, articles - 1
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

spring 声明式事务

Posted on 2011-01-08 21:52 疯狂 阅读(646) 评论(0)  编辑  收藏 所属分类: databasespring
     此文只是记录一下,如有问题给我留言。
    
TransactionTemplate template = new TransactionTemplate(transactionManager);
            template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
            template.execute(
new TransactionCallbackWithoutResult() {
                @Override
                
protected void doInTransactionWithoutResult(TransactionStatus status) {
                    
                        testDao.save(obj);
                    
                }

                
            }
);

 异常需要在外层catch 因为提交时在transaction而不是save炒作。
 
声明式事务主要用于:
  1:相对于配置式
 2:要将长事务分成小事务,在此期间其他事务将挂起(Suspend )直到当前事务提交完成

 

---------


只有注册用户登录后才能发表评论。


网站导航: