Search in sources :

Example 96 with FieldsonlyMapper

use of mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper in project generator by mybatis.

the class DynamicSqlTest method testFieldsOnlyselect.

@Test
public void testFieldsOnlyselect() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
        Fieldsonly record = new Fieldsonly();
        record.setDoublefield(11.22);
        record.setFloatfield(33.44);
        record.setIntegerfield(5);
        mapper.insert(record);
        record = new Fieldsonly();
        record.setDoublefield(44.55);
        record.setFloatfield(66.77);
        record.setIntegerfield(8);
        mapper.insert(record);
        record = new Fieldsonly();
        record.setDoublefield(88.99);
        record.setFloatfield(100.111);
        record.setIntegerfield(9);
        mapper.insert(record);
        List<Fieldsonly> answer = mapper.select(dsl -> dsl.where(fieldsonly.integerfield, isGreaterThan(5)));
        assertThat(answer.size()).isEqualTo(2);
        answer = mapper.select(SelectDSLCompleter.allRows());
        assertThat(answer.size()).isEqualTo(3);
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.dsql.mapper.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.dsql.model.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 97 with FieldsonlyMapper

use of mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper in project generator by mybatis.

the class DynamicSqlTest method testFieldsOnlyInsert.

@Test
public void testFieldsOnlyInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
        Fieldsonly record = new Fieldsonly();
        record.setDoublefield(11.22);
        record.setFloatfield(33.44);
        record.setIntegerfield(5);
        mapper.insert(record);
        List<Fieldsonly> answer = mapper.select(dsl -> dsl.where(fieldsonly.integerfield, isEqualTo(5)));
        assertThat(answer.size()).isEqualTo(1);
        Fieldsonly returnedRecord = answer.get(0);
        assertThat(returnedRecord.getIntegerfield()).isEqualTo(record.getIntegerfield());
        assertThat(returnedRecord.getDoublefield()).isEqualTo(record.getDoublefield());
        assertThat(returnedRecord.getFloatfield()).isEqualTo(record.getFloatfield());
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.dsql.mapper.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.dsql.model.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 98 with FieldsonlyMapper

use of mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper in project generator by mybatis.

the class DynamicSqlTest method testFieldsOnlySelectByExamplewithMultiInsert.

@Test
public void testFieldsOnlySelectByExamplewithMultiInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
        Fieldsonly record1 = new Fieldsonly();
        record1.setDoublefield(11.22);
        record1.setFloatfield(33.44);
        record1.setIntegerfield(5);
        Fieldsonly record2 = new Fieldsonly();
        record2.setDoublefield(44.55);
        record2.setFloatfield(66.77);
        record2.setIntegerfield(8);
        Fieldsonly record3 = new Fieldsonly();
        record3.setDoublefield(88.99);
        record3.setFloatfield(100.111);
        record3.setIntegerfield(9);
        mapper.insertMultiple(Arrays.asList(record1, record2, record3));
        List<Fieldsonly> answer = mapper.select(dsl -> dsl.where(fieldsonly.integerfield, isGreaterThan(5)));
        assertThat(answer.size()).isEqualTo(2);
        answer = mapper.select(SelectDSLCompleter.allRowsOrderedBy(fieldsonly.integerfield));
        assertThat(answer.size()).isEqualTo(3);
        assertThat(answer.get(0).getIntegerfield()).isEqualTo(5);
        assertThat(answer.get(1).getIntegerfield()).isEqualTo(8);
        assertThat(answer.get(2).getIntegerfield()).isEqualTo(9);
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.dsql.mapper.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.dsql.model.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 99 with FieldsonlyMapper

use of mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper in project generator by mybatis.

the class HierarchicalJava5Test method testFieldsOnlyCountByExample.

@Test
public void testFieldsOnlyCountByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
        Fieldsonly record = new Fieldsonly();
        record.setDoublefield(11.22);
        record.setFloatfield(33.44);
        record.setIntegerfield(5);
        mapper.insert(record);
        record = new Fieldsonly();
        record.setDoublefield(44.55);
        record.setFloatfield(66.77);
        record.setIntegerfield(8);
        mapper.insert(record);
        record = new Fieldsonly();
        record.setDoublefield(88.99);
        record.setFloatfield(100.111);
        record.setIntegerfield(9);
        mapper.insert(record);
        FieldsonlyExample example = new FieldsonlyExample();
        example.createCriteria().andIntegerfieldGreaterThan(5);
        long rows = mapper.countByExample(example);
        assertEquals(2, rows);
        example.clear();
        rows = mapper.countByExample(example);
        assertEquals(3, rows);
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsonlyExample(mbg.test.mb3.generated.mixed.hierarchical.model.FieldsonlyExample) SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.mixed.hierarchical.model.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 100 with FieldsonlyMapper

use of mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper in project generator by mybatis.

the class HierarchicalJava5Test method testFieldsOnlyInsert.

@Test
public void testFieldsOnlyInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsonlyMapper mapper = sqlSession.getMapper(FieldsonlyMapper.class);
        Fieldsonly record = new Fieldsonly(5, 11.22, 33.44);
        mapper.insert(record);
        FieldsonlyExample example = new FieldsonlyExample();
        example.createCriteria().andIntegerfieldEqualTo(5);
        List<Fieldsonly> answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
        Fieldsonly returnedRecord = answer.get(0);
        assertEquals(record.getIntegerfield(), returnedRecord.getIntegerfield());
        assertEquals(record.getDoublefield(), returnedRecord.getDoublefield());
        assertEquals(record.getFloatfield(), returnedRecord.getFloatfield());
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsonlyExample(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.FieldsonlyExample) SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Mapper.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.Fieldsonly) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)107 Test (org.junit.jupiter.api.Test)107 FieldsonlyMapper (mbg.test.mb3.generated.dsql.mapper.FieldsonlyMapper)9 Fieldsonly (mbg.test.mb3.generated.dsql.model.Fieldsonly)9 FieldsonlyMapper (mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper)8 Fieldsonly (mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly)8 FieldsonlyExample (mbg.test.mb3.generated.annotated.flat.model.subpackage.FieldsonlyExample)8 FieldsonlyMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsonlyMapper)8 Fieldsonly (mbg.test.mb3.generated.annotated.hierarchical.model.Fieldsonly)8 FieldsonlyExample (mbg.test.mb3.generated.annotated.hierarchical.model.FieldsonlyExample)8 FieldsonlyMapper (mbg.test.mb3.generated.flat.mapper.subpackage.FieldsonlyMapper)8 Fieldsonly (mbg.test.mb3.generated.flat.model.subpackage.Fieldsonly)8 FieldsonlyExample (mbg.test.mb3.generated.flat.model.subpackage.FieldsonlyExample)8 FieldsonlyMapper (mbg.test.mb3.generated.mixed.flat.mapper.FieldsonlyMapper)8 Fieldsonly (mbg.test.mb3.generated.mixed.flat.model.Fieldsonly)8 FieldsonlyExample (mbg.test.mb3.generated.mixed.flat.model.FieldsonlyExample)8 FieldsonlyMapper (mbg.test.mb3.generated.annotated.conditional.mapper.FieldsonlyMapper)7 Fieldsonly (mbg.test.mb3.generated.annotated.conditional.model.Fieldsonly)7 FieldsonlyExample (mbg.test.mb3.generated.annotated.conditional.model.FieldsonlyExample)7 FieldsonlyMapper (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.FieldsonlyMapper)7