use of mbg.test.mb3.generated.dsql.mapper.mbgtest.sub.TranslationMapper in project generator by mybatis.
the class DynamicSqlTest method testTranslationTable.
@Test
public void testTranslationTable() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
TranslationMapper mapper = sqlSession.getMapper(TranslationMapper.class);
Translation t = new Translation();
t.setId(1);
t.setTranslation("Spanish");
mapper.insert(t);
Translation t1 = new Translation();
t1.setId(2);
t1.setTranslation("French");
mapper.insert(t1);
Optional<Translation> returnedRecord = mapper.selectByPrimaryKey(2);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(t1.getId(), rr.getId());
assertEquals(t1.getTranslation(), rr.getTranslation());
});
t1.setTranslation("Italian");
mapper.updateByPrimaryKey(t1);
returnedRecord = mapper.selectByPrimaryKey(2);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(t1.getId(), rr.getId());
assertEquals(t1.getTranslation(), rr.getTranslation());
});
}
}
Aggregations