使用mybatis插入数据到数据库中,显示插入成功,且没有报错,但是数据库中并没有数据的原因
没有提交事务,有时没有配置自动提交事务的设置,所以需要手动提交事务,即 sqlSession.commit();
如下所示示例:
/**
* 添加期次
* @throws ParseException
*/
@Test
public void testAddBatch() throws ParseException {
SqlSession session = MybatisUtil.openSession();
BatchDao mapper = session.getMapper(BatchDao.class);//BatchDao为实体类的数据访问层接口
int count = mapper.addBatch(new Batch(