您的位置:首页 > 编程语言 > Java开发

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})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: