spring2.0以后声明式事务管理
2008-10-29 17:35
471 查看
基于注解式的
<?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: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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/goodhope/icbc/server/domain/Tuser.hbm.xml</value>
<value>com/goodhope/icbc/server/domain/WithDrawData.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> org.hibernate.dialect.PostgreSQLDialect </prop>
<prop key="hibernate.query.substitutions"> true 1, false 0 </prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<tx:annotation-driven/>
</beans>
在类或者方法上使用
@Transactional(rollbackFor={SatusException.class,NOEnoughException.class})
<?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: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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/goodhope/icbc/server/domain/Tuser.hbm.xml</value>
<value>com/goodhope/icbc/server/domain/WithDrawData.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect"> org.hibernate.dialect.PostgreSQLDialect </prop>
<prop key="hibernate.query.substitutions"> true 1, false 0 </prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<tx:annotation-driven/>
</beans>
在类或者方法上使用
@Transactional(rollbackFor={SatusException.class,NOEnoughException.class})
相关文章推荐
- 使用Spring 2.0 新特性实现声明式事务管理-基于XML Schema
- Spring 2.0声明式事务管理让你的事务轻松回滚!
- 使用Spring 2.0 新特性实现声明式事务管理-基于XML Schema
- 使用Spring 2.0 新特性实现声明式事务管理-基于Annotation
- Spring2.0中声明式事务管理(读spring2.0技术手册,林信良)
- Spring 2.0声明式事务管理让你的事务轻松回滚!
- 全面分析 Spring 的编程式事务管理及声明式事务管理--转
- Spring声明式事务管理之三:配置方式+实例
- Spring 事务配置管理,简单易懂,详细 [声明式]
- Spring的声明式事务管理
- spring事物配置,声明式事务管理和基于@Transactional注解的使用
- Spring 声明式事务管理----基于AspectJ的XML方式
- spring声明式事务管理:基于注解的方式
- Spring事务分析(2)--基于声明式的事务管理实现分析
- 全面分析 Spring 的编程式事务管理及声明式事务管理(转)
- 声明式事务管理--Spring
- spring支持编程式事务管理和声明式事务管理两种方式
- spring事物配置,声明式事务管理和基于@Transactional注解的使用
- 11月5日自定义标签与Spring声明式事务管理培训日记
- Spring的声明式事务管理(3)