Search in sources :

Example 86 with Fieldsonly

use of mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly in project generator by mybatis.

the class FlatJava5Test method testFieldsOnlyInsert.

@Test
public void testFieldsOnlyInsert() {
    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);
        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.annotated.flat.model.subpackage.FieldsonlyExample) SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 87 with Fieldsonly

use of mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly in project generator by mybatis.

the class FlatJava5Test method testFieldsOnlyDeleteByExample.

@Test
public void testFieldsOnlyDeleteByExample() {
    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);
        int rows = mapper.deleteByExample(example);
        assertEquals(2, rows);
        example = new FieldsonlyExample();
        List<Fieldsonly> answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsonlyExample(mbg.test.mb3.generated.annotated.flat.model.subpackage.FieldsonlyExample) SqlSession(org.apache.ibatis.session.SqlSession) FieldsonlyMapper(mbg.test.mb3.generated.annotated.flat.mapper.subpackage.FieldsonlyMapper) Fieldsonly(mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly) Test(org.junit.jupiter.api.Test)

Example 88 with Fieldsonly

use of mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly 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 89 with Fieldsonly

use of mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly 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 90 with Fieldsonly

use of mbg.test.mb3.generated.annotated.flat.model.subpackage.Fieldsonly 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)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)99 Test (org.junit.jupiter.api.Test)99 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