事务管理的五种方法Word格式文档下载.docx

上传人:b****6 文档编号:17307545 上传时间:2022-12-01 格式:DOCX 页数:8 大小:74.43KB
下载 相关 举报
事务管理的五种方法Word格式文档下载.docx_第1页
第1页 / 共8页
事务管理的五种方法Word格式文档下载.docx_第2页
第2页 / 共8页
事务管理的五种方法Word格式文档下载.docx_第3页
第3页 / 共8页
事务管理的五种方法Word格式文档下载.docx_第4页
第4页 / 共8页
事务管理的五种方法Word格式文档下载.docx_第5页
第5页 / 共8页
点击查看更多>>
下载资源
资源描述

事务管理的五种方法Word格式文档下载.docx

《事务管理的五种方法Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《事务管理的五种方法Word格式文档下载.docx(8页珍藏版)》请在冰豆网上搜索。

事务管理的五种方法Word格式文档下载.docx

?

xmlversion="

1.0"

encoding="

UTF-8"

>

beansxmlns="

http:

//www.springframework.org/schema/beans"

xmlns:

xsi="

//www.w3.org/2001/XMLSchema-instance"

context="

//www.springframework.org/schema/context"

aop="

//www.springframework.org/schema/aop"

xsi:

schemaLocation="

//www.springframework.org/schema/beans

http:

//www.springframework.org/schema/beans/spring-beans-2.5.xsd

//www.springframework.org/schema/context

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

//www.springframework.org/schema/aophttp:

//www.springframework.org/schema/aop/spring-aop-2.5.xsd"

<

beanid="

sessionFactory"

class="

org.springframework.orm.hibernate3.LocalSessionFactoryBean"

propertyname="

configLocation"

value="

classpath:

hibernate.cfg.xml"

/>

configurationClass"

org.hibernate.cfg.AnnotationConfiguration"

/bean>

!

--定义事务管理器(声明式的事务)-->

transactionManager"

org.springframework.orm.hibernate3.HibernateTransactionManager"

ref="

--配置DAO-->

userDaoTarget"

com.bluesky.spring.dao.UserDaoImpl"

userDao"

org.springframework.transaction.interceptor.TransactionProxyFactoryBean"

--配置事务管理器-->

target"

proxyInterfaces"

com.bluesky.spring.dao.GeneratorDao"

--配置事务属性-->

transactionAttributes"

props>

propkey="

*"

PROPAGATION_REQUIRED<

/prop>

/props>

/property>

/beans>

第二种方式:

所有Bean共享一个代理基类

transactionBase"

lazy-init="

true"

abstract="

parent="

第三种方式:

使用拦截器

transactionInterceptor"

org.springframework.transaction.interceptor.TransactionInterceptor"

beanclass="

org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"

beanNames"

list>

value>

*Dao<

/value>

/list>

interceptorNames"

transactionInterceptor<

第四种方式:

使用tx标签配置的拦截器

tx="

//www.springframework.org/schema/tx"

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

//www.springframework.org/schema/txhttp:

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

context:

annotation-config/>

component-scanbase-package="

com.bluesky"

tx:

adviceid="

txAdvice"

transaction-manager="

attributes>

methodname="

propagation="

REQUIRED"

/tx:

advice>

aop:

config>

pointcutid="

interceptorPointCuts"

expression="

execution(*com.bluesky.spring.dao.*.*(..))"

advisoradvice-ref="

pointcut-ref="

/aop:

第五种方式:

全注解

annotation-driventransaction-manager="

/

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 初中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1