use of mbg.test.mb3.generated.dsql.mapper.mbgtest.IdMapper in project generator by mybatis.
the class DynamicSqlTest method testIdTable.
@Test
public void testIdTable() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
IdMapper mapper = sqlSession.getMapper(IdMapper.class);
Id id = new Id();
id.setId(1);
id.setDescription("Spanish");
mapper.insert(id);
Id id1 = new Id();
id1.setId(2);
id1.setDescription("French");
mapper.insert(id1);
Optional<Id> returnedRecord = mapper.selectByPrimaryKey(2);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(id1.getId(), rr.getId());
assertEquals(id1.getDescription(), rr.getDescription());
});
id1.setDescription("Italian");
mapper.updateByPrimaryKey(id1);
returnedRecord = mapper.selectByPrimaryKey(2);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(id1.getId(), rr.getId());
assertEquals(id1.getDescription(), rr.getDescription());
});
}
}
Aggregations