spring-mybatis, xml transaction notification

Configure in mybatis.xml,

 

  <!-- Enable support for transaction annotations-->
 < tx :annotation-driven transaction-manager ="transactionManager" />


<!--事务拦截通知-->
<tx:advice id="txAdvice"  transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="add*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="insert*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="update*"propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="batchInsert*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="save*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="create*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="find*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="get*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
            <tx:method name="select*" propagation="REQUIRED" read-only="true"/>
            <tx:method name="query*" propagation="REQUIRED" read-only="true"/>
        </tx:attributes>
    </tx:advice>

    <!--aop-->
<aop:config proxy-target-class="true">
        <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.wonder..*.*(..))"/>
    </aop:config>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326265225&siteId=291194637