<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<!-- 事务代理拦截器的配置 -->
<bean id="baseTransactionProxy" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>在普通的java项目中通过main方法自行写了个批量添加操作,其中一个操作出现异常,事务回滚,可是在java web项目中当出现异常,未出现异常的操作却更新了数据表,请帮忙解决一下这个问题,谢谢各位同仁!
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref local="dataSource" />
</property>
</bean>
<!-- 事务代理拦截器的配置 -->
<bean id="baseTransactionProxy" abstract="true"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<property name="transactionAttributes">
<props>
<prop key="insert*">PROPAGATION_REQUIRED</prop>
<prop key="update*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>在普通的java项目中通过main方法自行写了个批量添加操作,其中一个操作出现异常,事务回滚,可是在java web项目中当出现异常,未出现异常的操作却更新了数据表,请帮忙解决一下这个问题,谢谢各位同仁!
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="find*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* *..dao.impl..*(..))" id="dao-pc"/>
<aop:pointcut expression="execution(* *..service.impl..*(..))" id="service-pc"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="dao-pc"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="service-pc"/>
</aop:config>
切面表达式什么的你自己改一改。
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>*Manager</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>transactionInterceptors</value>
</list>
</property>
</bean>我以前是配置拦截所有的manager