use of mbg.test.mb3.generated.dsql.miscellaneous.model.MyObject in project generator by mybatis.
the class MiscellaneousTest method testMyObjectDeleteByExample.
@Test
public void testMyObjectDeleteByExample() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
MyObjectMapper mapper = sqlSession.getMapper(MyObjectMapper.class);
MyObject record = new MyObject();
FirstName fn = new FirstName();
fn.setValue("Jeff");
record.setFirstname(fn);
record.setLastname("Smith");
record.setId1(1);
record.setId2(2);
mapper.insert(record);
record = new MyObject();
fn = new FirstName();
fn.setValue("Bob");
record.setFirstname(fn);
record.setLastname("Jones");
record.setId1(3);
record.setId2(4);
mapper.insert(record);
List<MyObject> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(2, answer.size());
int rows = mapper.delete(dsl -> dsl.where(myObject.lastname, isLike("J%")));
assertEquals(1, rows);
answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
}
}
Aggregations