=================================基于Hibernate的声明式事务===========================
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName">
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url">
<value>jdbc:oracle:thin:@localhost:1521:XUANFENG</value>
</property>
<property name="username">
<value>scott</value>
</property>
<property name="password">
<value>tiger</value>
</property>
</bean>
<!--此处是针对hibernate集成生成sessionFactory-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/xfl/bookmark/vo/Users.hbm.xml</value>
<value>org/xfl/bookmark/vo/Bookmark.hbm.xml</value>
</list>
</property>
</bean>
<!--声明事务-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!--生成代理事务类-->
<bean id="proxyDao"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="proxyInterfaces"><!--代理接口,可以实现多个接口-->
<list>
<value>org.xfl.bookmark.dao.IUserDAO</value>
</list>
</property>
<property name="target" value="usersDAO"></property><!--需要代理的目标类-->
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes"><!--事务类型-->
<props>
<prop key="*">PROPAGATION_REQUIRED,READONLY</prop>
</props>
</property>
</bean>
*********************针对上面的生成代理事务类,还可以用继承事务类的方式来实现*******
*********************将代理事务类去掉,添加以下代码***************************
<!--生成事务代理父类-->
<bean id="proxyParent" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
<property name="transactionManager">
<ref local="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED,readonly</prop>
</props>
</property>
</bean>
<!--写名要加入事务处理的类,继承上面的父类-->
<bean id="userManage" parent="proxyParent">
<property name="target">
<bean class="com.yourcompany.manage.UserManage"/>
</property>
</bean>