文章内容
https://blog.csdn.net/mmm333zzz/article/details/45288061
附上测试代码
@Controller
@Transactional
public class DemoController2 {
@Autowired
private CustomerDao customerDao;
@RequestMapping(value = "/demoController2/selectList.do")
public void selectList(HttpServletResponse response,HttpServletRequest resquest){
Customer customer=new Customer();
customer.setApplicationNO("D00021807040005");
customer.setId_card("11111");
System.out.println("更新数据开始");
customerDao.update(customer);
System.out.println("更新数据结束");
}
}
测试结果
2018-07-13 14:42:54,041 [http-bio-8080-exec-7] DEBUG [org.mybatis.spring.SqlSessionUtils] - Creating a new SqlSession
2018-07-13 14:42:54,042 [http-bio-8080-exec-7] DEBUG [org.mybatis.spring.SqlSessionUtils] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7cc6f37a] was not registered for synchronization because synchronization is not active
2018-07-13 14:42:54,044 [http-bio-8080-exec-7] DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Fetching JDBC Connection from DataSource
2018-07-13 14:42:54,049 [http-bio-8080-exec-7] DEBUG [org.mybatis.spring.transaction.SpringManagedTransaction] - JDBC Connection [jdbc:mysql://127.0.0.1:3306/test_zhou?characterEncoding=UTF-8, UserName=root@localhost, MySQL-AB JDBC Driver] will not be managed by Spring
2018-07-13 14:42:54,050 [http-bio-8080-exec-7] DEBUG [com.xxxx.core.dao.pushBusiness.CustomerDao.update] - ==> Preparing: update ap_customer SET id_card=? where applicationNO=?
2018-07-13 14:42:54,051 [http-bio-8080-exec-7] DEBUG [com.xxxx.core.dao.pushBusiness.CustomerDao.update] - ==> Parameters: 11111(String), D00021807040005(String)
2018-07-13 14:42:54,055 [http-bio-8080-exec-7] DEBUG [com.xxxx.core.dao.pushBusiness.CustomerDao.update] - <== Updates: 1
2018-07-13 14:42:54,055 [http-bio-8080-exec-7] DEBUG [org.mybatis.spring.SqlSessionUtils] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7cc6f37a]
2018-07-13 14:42:54,055 [http-bio-8080-exec-7] DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] - Returning JDBC Connection to DataSource
没有事务