anlingjing 2014-12-27 21:14 采纳率: 0%
浏览 4584

spring+mybatis异常不回滚

代码如下:
applicationContext-mybatis.xml

 <bean id="sSF" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="mapperLocations" value="classpath:com/telchina/**/*.xml"></property>
    </bean>
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.telchina"></property>
        <property name="sqlSessionFactoryBeanName" value="sSF"></property>
    </bean>

    <!-- 事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 拦截器方式配置事务 -->
    <tx:advice id="transactionAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="*" propagation="REQUIRED" rollback-for="java.lang.RuntimeException"/>
        </tx:attributes>
    </tx:advice>
    <aop:config>
        <aop:pointcut id="transactionPointcut" expression="execution(* com.telchina.app.service.impl.*Impl.*(..))" />
        <aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" />
    </aop:config>
 @Service("demoService")
public class DemoServiceImpl implements DemoService {
    @SuppressWarnings("rawtypes")
    @Override
    public String rollbackTest(List demoList) {
        // TODO Auto-generated method stub
        Iterator itr = demoList.iterator();
        while (itr.hasNext()) {
            Map demoMap = (Map) itr.next();
            demoMapper.updateDemo(demoMap);
            throw new RuntimeException("rollbackTest");
        }
        return "";
    }

}

List中传入了两个对象,总是能更新一个,事务不回滚,愁死了,求各位大侠指点!!!!

  • 写回答

3条回答 默认 最新

  • anlingjing 2014-12-27 21:15
    关注

    service有点长,没贴全,

     @Autowired
        private DemoMapper demoMapper;
        public void setDemoMapper(DemoMapper demoMapper) {
            this.demoMapper = demoMapper;
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?