我在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()做为一个事物来进行管理,请问我该怎么写?
解决方案 »
- 关于使用华为短信开发包发送和接收短信的问题。
- action中用freemarker输出list问题
- 再问个关于eclipse使用的问题
- JNDI有什么用?
- 请问各位高手,用LookupDispatchAction实现的action,在jsp页面中怎样利用javascript实现弹出窗口啊?
- 在CMP里如何处理自动编号的问题
- 我的项目改用STRUTS来得及吗? 请发言
- 用Xshell运行jar包出现无法建立数据源连接的问题
- maven spring3 hibernate4 Caused by: java.lang.ClassNotFoundException: org.hibe
- maven项目下css、js等静态文件路径如何引用?求大神讲解一波
- java ftp路径问题
- 通过myeclipse中发布到tomcat中运行没有问题,达成war包部署就出错
不妥 一般是这样吧 <tx:method name="*" read-only="true"/>只有配置的才有事务,其他都没有,要不然你是创建一个user时 掉用了com.AAA.service.impl.*)" 中其他方法就事务提交了
这样也就是说 如果com.AAA.service.impl里有个方法叫hello(),里边有增加,删除,这样他是怎么提交和回滚呢?...能加下您的qq么,问您几个问题么?