MyBatis中sqlSession操作数据库,不报错但无法实现数据修改(增、改、删)

时间:2018-04-18 14:00:20   收藏:0   阅读:242
public void addCustomerTest() throws Exception {
        SqlSession sqlSession = MyBatisUtils.getSession();
        CustomerMapper customerMapper = sqlSession.getMapper(CustomerMapper.class);
        Customer customer = new Customer();
        customer.setUsername("111");
        customer.setJobs("111");
        customer.setPhone("111");
        customerMapper.addCustomer(customer);
        sqlSession.commit();
        sqlSession.close();

    }

数据库查询操作可实现,但修改无法实现,且不报错,出现这种情况的原因之一:

事务忘记提交!

添加代码sqlSession.commit();

长点心就能少犯错误。

 

原文:https://www.cnblogs.com/wxywxy/p/8874308.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!