我在spring applicationContext.xml中配置了<!-- 配置事务管理器 -->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="within(com.AAA.service.impl.*)" id="servicePointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" />
</aop:config>比如说 com.AAA.service.impl下的 addUser()方法下遍有2个user需要添加
就是 2个user有一个没有添加成功都失败,这样写配置就不对,这样是一条user添加成功就commit,
我想把整体addUser()做为一个事物来进行管理,请问我该怎么写?
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="within(com.AAA.service.impl.*)" id="servicePointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" />
</aop:config>比如说 com.AAA.service.impl下的 addUser()方法下遍有2个user需要添加
就是 2个user有一个没有添加成功都失败,这样写配置就不对,这样是一条user添加成功就commit,
我想把整体addUser()做为一个事物来进行管理,请问我该怎么写?
解决方案 »
- 请教Java国际化问题
- struts1跳转 刷新数据的问题
- 问一个关于xml的问题(java语言)数据备份成xml恢复数据
- hibernate查询数据库没有问,但写数据库就出现下面错误
- 请问org.apache.commons.net.tftp包在哪下载?
- 郁闷.....关于JDK和TOMCAT,请教大家
- 用了struts以后jsp里面的菜单显示不出来了
- 在哪里可以找到一个比较完整的j2ee应用例子下载?
- 请问如何用java编程实现在excel插入图片呀?
- 怎么可以网页上按某个键就运行客户端某个应用程序,用applet可以吗???怎么做...救命呀..
- java ftp路径问题
- 通过myeclipse中发布到tomcat中运行没有问题,达成war包部署就出错
不妥 一般是这样吧 <tx:method name="*" read-only="true"/>只有配置的才有事务,其他都没有,要不然你是创建一个user时 掉用了com.AAA.service.impl.*)" 中其他方法就事务提交了
这样也就是说 如果com.AAA.service.impl里有个方法叫hello(),里边有增加,删除,这样他是怎么提交和回滚呢?...能加下您的qq么,问您几个问题么?