zoukankan      html  css  js  c++  java
  • 事务不起作用 Closing non transactional SqlSession

    In proxy mode (which is the default), only external method calls coming in through the proxy are intercepted. This means that self-invocation, in effect, a method within the target object calling another method of the target object, will not lead to an actual transaction at runtime even if the invoked method is marked with @Transactional.

    spring文档地址 :

    http://docs.spring.io/spring/docs/4.2.0.RC1/spring-framework-reference/htmlsingle/#transaction-declarative-annotations

    说明: 代理模式中,只拦截外部方法调用,开启事务。类内部调用无法实现事务控制。

    错误示例:

    public class Tx {
        
        public void a(){
            b();
        }
        
        @Transactional(propagation = Propagation.REQUIRED)
        public void b(){
            
        }
    
    }

    正确示例:

    public class Tx {
        
        @Transactional(propagation = Propagation.REQUIRED)
        public void a(){
            b();
        }
        
        
        public void b(){
            
        }
    
    }
  • 相关阅读:
    静态与非静态(转改)
    关于odp.net的FetchSize属性
    SQL_SERVER 导oracle(转)
    win7电脑上wifi
    Oracle对象统计信息
    SQL_SERVER 连接oracle(转)
    linq in 语法
    关于引擎的设计
    温习设计模式
    技巧类
  • 原文地址:https://www.cnblogs.com/zno2/p/4875527.html
Copyright © 2011-2022 走看看