Spring配置事物管理

来源:互联网 发布:车双头螺纹编程 编辑:程序博客网 时间:2024/04/29 07:57
 <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <aop:aspectj-autoproxy proxy-target-class="true"/>

    <tx:annotation-driven transaction-manager="transactionManager"/>

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="save*" propagation="REQUIRED"/>
            <tx:method name="update*" propagation="REQUIRED"/>
            <tx:method name="remove*" propagation="REQUIRED"/>
            <tx:method name="delete*" propagation="REQUIRED"/>
            <tx:method name="*" read-only="true"/>
        </tx:attributes>
    </tx:advice>
    <aop:config>
        <aop:pointcut id="allMethod" expression="execution( * cn.les.ldbz.jframe.core.BaseServiceImpl.*(..))
                                    ||execution(* cn.les.ldbz.system.service.*.*(..))||execution(* cn.les.ldbz.ylbg.service.*.*(..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="allMethod"/>
    </aop:config>

原创粉丝点击