use of mbg.test.mb3.generated.dsql.model.Pkfields in project generator by mybatis.
the class HierarchicalJava5Test method testPKFieldsSelectByExampleEscapedFields.
@Test
public void testPKFieldsSelectByExampleEscapedFields() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
Pkfields record = new Pkfields();
record.setFirstname("Fred");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(1);
record.setWierdField(11);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Wilma");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(2);
record.setWierdField(22);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Pebbles");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(3);
record.setWierdField(33);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Barney");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(1);
record.setWierdField(44);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Betty");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(2);
record.setWierdField(55);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Bamm Bamm");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(3);
record.setWierdField(66);
mapper.insert(record);
List<Integer> values = new ArrayList<>();
values.add(11);
values.add(22);
PkfieldsExample example = new PkfieldsExample();
example.createCriteria().andWierdFieldLessThan(40).andWierdFieldIn(values);
example.setOrderByClause("ID1, ID2");
List<Pkfields> answer = mapper.selectByExample(example);
assertEquals(2, answer.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.dsql.model.Pkfields in project generator by mybatis.
the class DynamicSqlTest method testPKFieldsInsert.
@Test
public void testPKFieldsInsert() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
Pkfields record = new Pkfields();
record.setDatefield(LocalDate.now());
record.setDecimal100field(10L);
record.setDecimal155field(new BigDecimal("15.12345"));
record.setDecimal30field((short) 3);
record.setDecimal60field(6);
record.setFirstname("Jeff");
record.setId1(1);
record.setId2(2);
record.setLastname("Butler");
record.setTimefield(LocalTime.of(13, 2, 4));
record.setTimestampfield(LocalDateTime.now());
record.setStringboolean(true);
mapper.insert(record);
Optional<Pkfields> returnedRecord = mapper.selectByPrimaryKey(2, 1);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(record.getDatefield(), rr.getDatefield());
assertEquals(record.getDecimal100field(), rr.getDecimal100field());
assertEquals(record.getDecimal155field(), rr.getDecimal155field());
assertEquals(record.getDecimal30field(), rr.getDecimal30field());
assertEquals(record.getDecimal60field(), rr.getDecimal60field());
assertEquals(record.getFirstname(), rr.getFirstname());
assertEquals(record.getId1(), rr.getId1());
assertEquals(record.getId2(), rr.getId2());
assertEquals(record.getLastname(), rr.getLastname());
assertEquals(record.getTimefield(), rr.getTimefield());
assertThat(record.getTimestampfield()).isCloseTo(rr.getTimestampfield(), within(1, ChronoUnit.MILLIS));
assertEquals(record.isStringboolean(), rr.isStringboolean());
});
}
}
use of mbg.test.mb3.generated.dsql.model.Pkfields in project generator by mybatis.
the class DynamicSqlTest method testPKfieldsDeleteByPrimaryKey.
@Test
public void testPKfieldsDeleteByPrimaryKey() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
Pkfields record = new Pkfields();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setId1(1);
record.setId2(2);
mapper.insert(record);
int rows = mapper.deleteByPrimaryKey(2, 1);
assertEquals(1, rows);
List<Pkfields> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(0, answer.size());
}
}
use of mbg.test.mb3.generated.dsql.model.Pkfields in project generator by mybatis.
the class DynamicSqlTest method testEquals2.
@Test
public void testEquals2() {
Pkfields pkfields1 = new Pkfields();
Pkfields pkfields2 = new Pkfields();
assertEquals(pkfields2, pkfields1);
}
use of mbg.test.mb3.generated.dsql.model.Pkfields in project generator by mybatis.
the class DynamicSqlTest method testPKFieldsdelete.
@Test
public void testPKFieldsdelete() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
Pkfields record = new Pkfields();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setId1(1);
record.setId2(2);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Bob");
record.setLastname("Jones");
record.setId1(3);
record.setId2(4);
mapper.insert(record);
List<Pkfields> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(2, answer.size());
int rows = mapper.delete(dsl -> dsl.where(pkfieldstable.lastname, isLike("J%")));
assertEquals(1, rows);
answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
}
}
Aggregations