Search in sources :

Example 61 with MyObject

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());
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) FirstName(mbg.test.common.FirstName) MyObject(mbg.test.mb3.generated.dsql.miscellaneous.model.MyObject) MyObjectMapper(mbg.test.mb3.generated.dsql.miscellaneous.mapper.MyObjectMapper) Test(org.junit.jupiter.api.Test)

Aggregations

FirstName (mbg.test.common.FirstName)61 Test (org.junit.jupiter.api.Test)61 SqlSession (org.apache.ibatis.session.SqlSession)60 MyObject (mbg.test.mb3.generated.miscellaneous.model.MyObject)16 MyObjectMapper (mbg.test.mb3.generated.annotated.miscellaneous.mapper.MyObjectMapper)15 MyObject (mbg.test.mb3.generated.annotated.miscellaneous.model.MyObject)15 MyObjectMapper (mbg.test.mb3.generated.dsql.miscellaneous.mapper.MyObjectMapper)15 MyObject (mbg.test.mb3.generated.dsql.miscellaneous.model.MyObject)15 MyMapper (mbg.test.mb3.generated.miscellaneous.mapper.MyMapper)15 MyObjectMapper (mbg.test.mb3.generated.mixed.miscellaneous.mapper.MyObjectMapper)15 MyObject (mbg.test.mb3.generated.mixed.miscellaneous.model.MyObject)15 Date (java.util.Date)13 MyObjectCriteria (mbg.test.mb3.generated.annotated.miscellaneous.model.MyObjectCriteria)11 MyObjectCriteria (mbg.test.mb3.generated.miscellaneous.model.MyObjectCriteria)11 MyObjectCriteria (mbg.test.mb3.generated.mixed.miscellaneous.model.MyObjectCriteria)11 MyTime (mbg.test.common.MyTime)9 ArrayList (java.util.ArrayList)5 MyObjectKey (mbg.test.mb3.generated.annotated.miscellaneous.model.MyObjectKey)5 MyObjectKey (mbg.test.mb3.generated.miscellaneous.model.MyObjectKey)5 MyObjectKey (mbg.test.mb3.generated.mixed.miscellaneous.model.MyObjectKey)5