<?xml version="1.0" encoding="UTF-8"?>

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

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

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

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

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

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd

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

http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 配置sessionFactory的方式 -->

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="configLocation">

<value>classpath:config/hibernate.cfg.xml</value>

</property>

</bean>

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

<property name="sessionFactory" ref="sessionFactory"></property>

</bean>

<!-- 第一种配置事务的方式 ,tx-->

<!--

<tx:advice id="txadvice" transaction-manager="transactionManager">

<tx:attributes>

<tx:method name="add*" propagation="REQUIRED" no-rollback-for="com.exception.MyRuntimeException"/>

<tx:method name="modify*" propagation="REQUIRED" no-rollback-for="com.exception.MyRuntimeException"/>

<tx:method name="del*" propagation="REQUIRED"/>

<tx:method name="*" propagation="REQUIRED" read-only="true"/>

</tx:attributes>

</tx:advice>

<aop:config>

<aop:pointcut expression="execution(* com.dao.*.*(..))" id="daoMethod"/>

<aop:advisor advice-ref="txadvice" pointcut-ref="daoMethod"/>

</aop:config>

-->

<!-- 第二种配置事务的方式,代理 -->

<bean id="transactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">

<!-- 使用cglib方式实现动态代理

<property name="proxyTargetClass" value="true"></property>

-->

<property name="transactionManager" ref="transactionManager"></property>

<property name="transactionAttributes">

<props>

<prop key="add*">PROPAGATION_REQUIRED, +RuntimeException</prop>

<prop key="modify*">PROPAGATION_REQUIRED, +com.exception.MyRuntimeException</prop>

<prop key="del*">PROPAGATION_REQUIRED</prop>

<prop key="*">PROPAGATION_REQUIRED, readOnly</prop>

</props>

</property>

</bean>

<bean id="userDao" parent="transactionProxy">

<property name="target">

<!-- 直接写bean来代替ref标签的链接方式 -->

<bean class="com.dao.impl.UserDaoImpl">

<property name="sessionFactory" ref="sessionFactory"></property>

</bean>

</property>

</bean>

</beans>

SSH2配置事务的两种方式的更多相关文章

  1. MyBatis配置数据源的两种方式

    ---------------------siwuxie095                                     MyBatis 配置数据源的两种方式         1.配置方 ...

  2. Spring配置事务的五种方式

    Java事务的类型有三种: JDBC事务. 可以将多个 SQL 语句结合到一个事务中.JDBC 事务的一个缺点是事务的范围局限于一个数据库连接.一个 JDBC 事务不能跨越多个数据库 JTA(Java ...

  3. spring配置属性的两种方式

    spring配置属性有两种方式,第一种方式通过context命名空间中的property-placeholder标签 <context:property-placeholder location ...

  4. web.config文件中配置数据库连接的两种方式

    web.config文件中配置数据库连接的两种方式 标签: 数据库webconfig 2015-04-28 18:18 31590人阅读 评论(1)收藏举报    分类: 数据库(74)  在网站开发 ...

  5. springmvc配置AOP的两种方式

    spingmvc配置AOP有两种方式,一种是利用注解的方式配置,另一种是XML配置实现. 应用注解的方式配置: 先在maven中引入AOP用到的依赖 <dependency> <gr ...

  6. Spring Boot配置过滤器的两种方式

    过滤器(Filter)是Servlet中常用的技术,可以实现用户在访问某个目标资源之前,对访问的请求和响应进行拦截,常用的场景有登录校验.权限控制.敏感词过滤等,下面介绍下Spring Boot配置过 ...

  7. DJango中开启事务的两种方式

    目录 Django中开启事务的两种方式 第一种 第二种 Django中开启事务的两种方式 第一种 from django.db import transaction with transaction. ...

  8. jdk配置java_home的两种方式

    在开发java项目的时候,要先安装jdk,安装完jdk之后我们要配置环境变量.今天说一下java home环境变量. 配置环境变量有两种方式,一种就是在计算机的环境变量里面配置.这个是很简单的.如果你 ...

  9. guice基本使用,配置模块的两种方式(三)

    guice是使用module进行绑定的,它提供了两种方式进行操作. 第一种是继承AbstractModule抽象类. package com.ming.user.test; import com.go ...

随机推荐

  1. ios 自己定义导航栏和切割线

    自己定义导航栏: // CustomNaviBarView.h #import <UIKit/UIKit.h> @interface CustomNaviBarView : UIView ...

  2. C++入门学习——标准模板库之vector

    vector(向量容器),是 C++ 中十分实用一个容器.vector 之所以被觉得是一个容器,是由于它可以像容器一样存放各种类型的对象,简单地说,vector 是一个可以存放随意类型(类型可以是in ...

  3. 21. DNS 配置和端口检测

    一.将本机的 DNS 配置为 8.8.8.8 ,用 nslookup (还可以使用 host.dig)验证 # 修改配置文件     # vim /etc/resolv.conf # 在文件的最后加入 ...

  4. VS2012 拆分视图按钮不见,代码,设计

    工具--选项--HTML设计器 然后重启就有了.

  5. JS判断RadioButtonList是否有选中项

    提交表单之前对RadioButtonList控件的选中项进行判断: 方法一: <script type="text/javascript"> function chec ...

  6. linux字体安装

    Google查了一下,果然Windows下的ttf字体与GNOME是兼容的!我立即确定了我的方案——使用Windows下的“微软雅黑”体作为桌面和应用程序的默认字体! 1. 首先获得一套“微软雅黑”字 ...

  7. Ubutu命令 笔记积累

    1 man command 查询帮助 查询结果会有 name    synopsis(概要)  description 2 terminal 中快捷键: Ctrl +u 撤销 Ctrl +l  清屏 ...

  8. (原)vs2013编译boost1.60库

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5394236.html 参考网址: http://www.cnblogs.com/chuncn/arch ...

  9. Bone Collector(ZeroOnebag)

    Bone Collector Problem Description Many years ago , in Teddy’s hometown there was a man who was call ...

  10. QPainter就是手里的作图工具,只需要三洋东西:笔(颜色,宽度,样式),字体(写字),刷子(大面积作画),这里有三个典型例子

    设置笔和字体以后,就可以写字了: void MainWindow::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter painter ...