Spring三种事务处理方式
</bean>
<!--数据源-->
<bean id="datasource" value="${jdbc.driverclassname}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<!--spring jdbc模板bean,它注入了上面的数据源-->
<bean id="jdbctemplate" ref="datasource"/>
</bean>
</bean>
</beans>
</bean>
<!--业务类bean-->
<bean id="userserviceimpltarget" ref="userjdbcdao"/>
</bean>
<property name="target" ref="userserviceimpltarget"/><!--指定业务bean-->
<property name="transactionattributes"><!--事务的属性设置列表-->
<props>
<prop key="add*">propagation_required,isolation_serializable</prop>
<!--设置事务为只读时,添加数据将会产生异常-->
<!--<prop key="add*">propagation_required,isolation_serializable,readonly</prop>-->
</props>
</property>
</bean>
<beans .....
xmlns:tx="http://www.springframework.org/schema/tx"
xsp:schemalocation="http://www.springframework.org/schema/beans
...........
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
</bean>
</bean>
<tx:attributes>
<tx:method name="add*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!--用aop:config声明要进行事务增强的切面-->
<aop:config>
<aop:pointcut id="servicemethod"
expression="execution(* com.service..add*(..))"/>
<aop:advisor pointcut-ref="servicemethod" advice-ref="txadvice"/>
</aop:config>
</beans>
</bean>
</bean>
?