急急急!Struts2+spring+ibatis+oracle service层事务不能回滚,请高手指点

问题描述

事务配置<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd"><beanid="ghm_DataSource"class="org.springframework.jndi.JndiObjectFactoryBean"><propertyname="jndiName"><value>java:comp/env/jdbc/ghm_jdbc</value></property></bean><beanid="ghk_DataSource"class="org.springframework.jndi.JndiObjectFactoryBean"><propertyname="jndiName"><value>java:comp/env/jdbc/ghk_jdbc</value></property></bean><beanid="ghc_DataSource"class="org.springframework.jndi.JndiObjectFactoryBean"><propertyname="jndiName"><value>java:comp/env/jdbc/ghc_jdbc</value></property></bean><beanid="ghm_sqlMapClient"class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"><propertyname="configLocation"><value>classpath:ghy-SqlMap-Config.xml</value></property><propertyname="dataSource"ref="ghm_DataSource"></property></bean><beanid="ghk_sqlMapClient"class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"><propertyname="configLocation"><value>classpath:ghy-SqlMap-Config.xml</value></property><propertyname="dataSource"ref="ghk_DataSource"></property></bean><beanid="ghc_sqlMapClient"class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"><propertyname="configLocation"><value>classpath:ghy-SqlMap-Config.xml</value></property><propertyname="dataSource"ref="ghc_DataSource"></property></bean><beanid="jotm"class="org.springframework.transaction.jta.JotmFactoryBean"/><beanid="transactionManager"class="org.springframework.transaction.jta.JtaTransactionManager"><propertyname="userTransaction"ref="jotm"/></bean><tx:adviceid="txAdvice"transaction-manager="transactionManager"><tx:attributes><tx:methodname="delete*"rollback-for="Exception"/><tx:methodname="save*"rollback-for="Exception"/><tx:methodname="update*"rollback-for="Exception"/><tx:methodname="add*"rollback-for="Exception"/><tx:methodname="select*"read-only="true"/><tx:methodname="get*"read-only="true"/><tx:methodname="find*"read-only="true"/><tx:methodname="query*"read-only="true"/></tx:attributes></tx:advice><beanid="transactionTemplate"class="org.springframework.transaction.support.TransactionTemplate"><propertyname="transactionManager"><refbean="transactionManager"/></property></bean><aop:config><!--切入点--><aop:pointcutid="serviceOperation"expression="execution(*com.speed.speedadmin.ghy.service..*.*(..))"/><aop:advisorpointcut-ref="serviceOperation"advice-ref="txAdvice"/><!--适配器--></aop:config></beans>

service层代码:publicvoidaddChannelInfo(GhManChannelManagerVovo){//TODOAuto-generatedmethodstubStringchannelId=ghManChannelManagerDao.addChannelInfo(vo);//成功插入vo.setChannelId(channelId);ghManChannelManagerDao.addChannelDetail(vo);//由于vo中的某个属性不合法,将产生异常,但是第一个表中的数据已插入,不能回滚是配置的问题吗}

解决方案

解决方案二:
ghManChannelManagerDao.addChannelInfo(vo)ghManChannelManagerDao.addChannelDetail(vo)

以上两个调用,应该是执行完第一个后,你的连接断开了,当执行第二个时,又重新打开了连接,本质上就是两个session,所以不能rollback。
解决方案三:
service层手动添加事务控制代码试一下
解决方案四:
引用1楼wmxcn2000的回复:

ghManChannelManagerDao.addChannelInfo(vo)ghManChannelManagerDao.addChannelDetail(vo)

以上两个调用,应该是执行完第一个后,你的连接断开了,当执行第二个时,又重新打开了连接,本质上就是两个session,所以不能rollback。

是的,日志显示的conn编码确实不一样,那应该如何做呢,新手不懂,望指教,谢谢
解决方案五:
引用2楼pengdott的回复:

service层手动添加事务控制代码试一下

能否给个例子,谢谢
解决方案六:
高手在哪里?
解决方案七:
手动添加事物控制代码,添加注解,在需要事物控制的方法上添加事物控制注解

时间: 2024-08-01 03:09:50

急急急!Struts2+spring+ibatis+oracle service层事务不能回滚,请高手指点的相关文章

struts2+spring+ibatis整合需要哪些jar包

问题描述 struts2+spring+ibatis整合需要哪些jar包 struts2+spring+ibatis整合需要哪些jar包

ssi环境搭建需求包-跪求struts2 spring ibatis整合的jar包

问题描述 跪求struts2 spring ibatis整合的jar包 哪位大神还存有这些jar包,新手跪求赞助,1158388028@qq.com,有的请发邮箱,谢谢,新手c币不多,求大神帮忙 解决方案 这个 啊 建议你以后用 intellij idea 研究一下,,以后管理jar 包用 maven 很方便,,不然,只jar包就能烦死你 解决方案二: 参考这个看看是否有帮助 Struts2+Ibatis+Spring例子http://download.csdn.net/download/wan

Struts2+spring+ibatis集成配置

问题描述 struts2+spring+ibatis如何进行集成配置,那位大虾能把集成步骤及配置贴出来..小弟感激不尽 解决方案 解决方案二:这个只能你自己去找资料按照上面的一步步做如果报错了再来找方法告诉你怎么配也是肯定会报错的就算是源码给你可能也要报错解决方案三:每一个框架的搭建方式都一样,提醒你一点可能会出错的地方:struts和spring整合需要一个jar包:struts-spring-plugin-2.1.1.0.jar解决方案四:struts1.2metoo解决方案五:哈,已经解决

spring事务注解@Transactional事务不回滚

问题描述 spring事务注解@Transactional事务不回滚 如题: public interface A { public void A(); } public class B implements A{ public void A(){ B();} @Transactional public void B(){ //删除数据 //两者之前发生异常了... //添加数据 } } 如果将@Transactional注解放在某一service实现类的某一非入口方法,发现数据不会回滚,请问大

求大神帮忙 spring aop 方式事务不回滚怎么搞?

问题描述 求大神帮忙 spring aop 方式事务不回滚怎么搞? spring 版本 4.1.7 代码如下: 表: CREATE TABLE users (id int(11) unsigned NOT NULL AUTO_INCREMENT,nick_name varchar(100) DEFAULT NULL,password varchar(100) DEFAULT NULL, PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAU

spring 事务 回滚-spring @Transactional 事务不能回滚

问题描述 spring @Transactional 事务不能回滚 在spring的配置文件里配置如下: <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven transaction-manager="txManager"/> <!-- a PlatformTransactionManager is sti

服务器-Spring mvc hibernate 有个上传附件问题 请高手给我解决下

问题描述 Spring mvc hibernate 有个上传附件问题 请高手给我解决下 MultipartFile photo 报错 File has been moved - cannot be read again Spring mvc 的上传附件 方法: if(photos.getSize() != 0){ String name = photo.getOriginalFilename(); String str = name.substring(0,name.lastIndexOf(".

急 合强智能办公系统 突然提示未检测到加密盒或初始化加密盒 请高手指点如何解决

问题描述 急合强智能办公系统突然提示未检测到加密盒或初始化加密盒请高手指点如何解决?使用的是lotusdominoserver之前使用的是正常的,重启服务器后就提示了.加密狗已插入. 解决方案 解决方案二:你应该去找集成商解决方案三:该回复于2009-08-04 11:21:47被版主删除解决方案四:有可能是加密锁坏了,或如果系统重装,那要重新安装加密锁的驱动解决方案五:查看狗是否正常插入,正常时绿灯常亮,嘿嘿···建议换个usb插口再到后台初始化,一般不会出现什么大问题的.

ibatis+spring mvc事务不能回滚

问题描述 最近才接触spring MVC和ibates,现在我需要配置事务回滚,但是倒腾了一天还是不行,熟悉的朋友帮忙看看: applicationContext.xml文件配置: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w