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();
}
}
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();
}
}
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);
}
}
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());
}
}
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);
}
}
Aggregations