rorom 2012-07-09 10:05
浏览 154

召唤前辈.mybaits事务问题

事务貌似没有生效,后面出错了也不回滚,日志如下:

2012-07-08 17:11:04,998 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating SqlSession with JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@9fe84e]
2012-07-08 17:11:04,998 [main] DEBUG java.sql.Connection - ooo Connection Opened
2012-07-08 17:11:05,030 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@9fe84e] will not be managed by Spring
2012-07-08 17:11:05,030 [main] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c20eb7] was not registered for synchronization because synchronization is not active
2012-07-08 17:11:05,170 [main] DEBUG java.sql.PreparedStatement - ==> Executing: select * from user where user_id=? 
2012-07-08 17:11:05,170 [main] DEBUG java.sql.PreparedStatement - ==> Parameters: 1(Integer)
2012-07-08 17:11:05,202 [main] DEBUG java.sql.ResultSet - <== Columns: user_id, login_name
2012-07-08 17:11:05,202 [main] DEBUG java.sql.ResultSet - <== Row: 1, zhangsan
2012-07-08 17:11:05,217 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1c20eb7]
2012-07-08 17:11:05,217 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Creating SqlSession with JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@13d1402]
2012-07-08 17:11:05,217 [main] DEBUG java.sql.Connection - ooo Connection Opened
2012-07-08 17:11:05,217 [main] DEBUG org.mybatis.spring.transaction.SpringManagedTransaction - JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection@13d1402] will not be managed by Spring
2012-07-08 17:11:05,217 [main] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@14b6b02] was not registered for synchronization because synchronization is not active
2012-07-08 17:11:05,264 [main] DEBUG java.sql.PreparedStatement - ==> Executing: update user set version = version + 1 where user_id = ? 
2012-07-08 17:11:05,264 [main] DEBUG java.sql.PreparedStatement - ==> Parameters: 1(Integer)
2012-07-08 17:11:05,295 [main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@14b6b02]


配置是这样的:


  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
     <property name="dataSource" ref="dataSource"/>
  </bean>

<bean id="transactionManager"      class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
     <property name="dataSource" ref="dataSource" />
  </bean>

java代码:

@Transactional
public void doAccount(Bean b) throws Exception{
  User user = userMapper.selectUserByUserId(b.getUserId());
  ...
  userMapper.updateUserAccount(b);
  ...
  if(paymentMapper.insertPayment(b) != 1){
throw new Exception();
  } 

}

目前的测试是到paymentMapper.insertPayment这里抛了异常,数据并没有进去.但是之前的update数据却没有回滚.以前没有用过mybaits不太了解.忘大神相助.
问题补充
主要是这句话是什么情况看不懂:
[main] DEBUG org.mybatis.spring.SqlSessionUtils - Closing no transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@b799cf]

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 为啥快手广告联盟的广告这么难出来
    • ¥15 k8s集群重启后,kubelet一直报systemctl restart kubelet.service "Failed to delete cgroup paths"
    • ¥15 微信小程序构建工具类发布到npm,install后报错
    • ¥15 amesim液压仿真问题
    • ¥15 MATLAB优化设计
    • ¥15 ANN预测模型 200大米
    • ¥20 优秀学生的问题 oj java
    • ¥15 scratch-gui 如何集成进 react native
    • ¥15 把全局悬浮窗改为局内悬浮窗
    • ¥15 Excel vba编程调用word如何读取换行符