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>
------解决方案--------------------