SSH事务配置全集
2013-04-08 18:14
183 查看
配置声明式事务的方法如下:
完整的applicationContext.xml
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager"/> <property name="transactionAttributes"> <props> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="regedit*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="do*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"> <list> <value>baseTransactionProxy</value> </list> </property> <property name="beanNames"> <list> <value>*Service</value> </list> </property> </bean>
完整的applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="helloService" class="com.tarena.service.HelloService">
<property name="str" value="hello"></property>
</bean>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url" value="jdbc:mysql://localhost:3306/cle">
</property>
<property name="username" value="root"></property>
<property name="password" value="root1234"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
<property name="dataSource" ref="dataSource"></property>
<!--
<property name="mappingResources">
<list>
<value>com\tarena\entity\User.hbm.xml</value>
</list>
</property>
-->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate"
class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager"/> <property name="transactionAttributes"> <props> <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="add*">PROPAGATION_REQUIRED</prop> <prop key="create*">PROPAGATION_REQUIRED</prop> <prop key="update*">PROPAGATION_REQUIRED</prop> <prop key="delete*">PROPAGATION_REQUIRED</prop> <prop key="save*">PROPAGATION_REQUIRED</prop> <prop key="regedit*">PROPAGATION_REQUIRED</prop> <prop key="remove*">PROPAGATION_REQUIRED</prop> <prop key="do*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"> <list> <value>baseTransactionProxy</value> </list> </property> <property name="beanNames"> <list> <value>*Service</value> </list> </property> </bean>
<bean id="userDao" class="com.tarena.dao.UserDaoImpl">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
<bean id="userService" class="com.tarena.service.UserServiceImpl">
<property name="userDao" ref="userDao"></property>
</bean>
<bean id="loginAction" class="com.tarena.action.LoginAction">
<property name="userService" ref="userService"></property>
</bean>
</beans>
相关文章推荐
- SSH中 c3po 配置和事务处理配置(注解方式)
- SSH深度历险(六) 深入浅出----- Spring事务配置的五种方式
- spring 管理的事务。个人理解(SSH项目注解配置)
- SSH深度历险(六) 深入浅出----- Spring事务配置的五种方式
- SSH配置中Spring对Hib的自动事务处理
- SSH中事务配置详解
- SSH事务配置
- ssh-配置事务管理器
- SSH配置中Spring对Hib的自动事务处理
- SSH添加事务配置事务
- SSH整合-关于Spring中applicationContext.xml文件对于事务的一些配置
- SSH中事务配置详解
- SSH中事务配置详解
- SSH深度历险(六) 深入浅出----- Spring事务配置的五种方式
- SSH中事务配置详解(使用tx标签配置的拦截器)
- 【转】 SSH事务配置大全
- SSH 配置自动提交事务
- SSH整合时,基于注解的事务管理的配置方式
- spring_day4_06-ssh整合(事务配置)
- spring入门(14)ssh中事务处理spring配置文件