java-spring事务管理部分代码主要代码

此处以一个applicationContext.xml文件头部配置文件为例


<beansxmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:context="http://www.springframework.org/schema/context"

       xmlns:aop="http://www.springframework.org/schema/aop"<!---------要添加的------------->

       xmlns:tx="http://www.springframework.org/schema/tx"<!---------要添加的------------->

       xsi:schemaLocation="http://www.springframework.org/schema/beans

       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

       http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context-3.0.xsd

       http://www.springframework.org/schema/aop <!---------要添加的------------->

       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd<!---------要添加的------------->

       http://www.springframework.org/schema/tx <!---------要添加的------------->

       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"><!---------要添加的------------->


//该处是配置事务管理的代码


<!--配置hibernate的事务管理器 -->

    <bean id="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">

        <propertyname="sessionFactory"ref="sessionFactory"/>

    </bean>

    <tx:adviceid="txadvice"transaction-manager="txManager">

    <tx:attributes>

        <tx:methodname="save*"propagation="REQUIRED"isolation="DEFAULT"/>

        <tx:methodname="delete*"propagation="REQUIRED"isolation="DEFAULT"/>

        <tx:methodname="find*"read-only="false"/>

        <tx:methodname="get*"read-only="false"/>

    </tx:attributes>

    </tx:advice> 

<!--配置切面 -->

    <aop:config>

        <aop:pointcutid="commonPointcut"expression="execution(* *..service..*.*(..))"/>

        <aop:advisoradvice-ref="txadvice"pointcut-ref="commonPointcut"/>

    </aop:config>

    <beanid="hibernateTemplate"class="org.springframework.orm.hibernate3.HibernateTemplate">

        <propertyname="sessionFactory"ref="sessionFactory"/>

    </bean>

    <beanid="baseDao"class="com.util.dao.imp.BaseDao">

      <propertyname="hibernateTemplate"><refbean="hibernateTemplate"/></property>

    </bean>

    <beanid="baseService"class="com.util.service.imp.BaseService"abstract="true"/>

   

</beans>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GFanStudio-LeeSir

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值