use of mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper in project generator by mybatis.
the class HierarchicalJava5Test method testPKBlobsSelectByExampleWithoutBlobs.
@Test
public void testPKBlobsSelectByExampleWithoutBlobs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
PkblobsWithBLOBs record = new PkblobsWithBLOBs(3, generateRandomBlob(), generateRandomBlob(), "Long String 1");
mapper.insert(record);
record = new PkblobsWithBLOBs(6, generateRandomBlob(), generateRandomBlob(), "Long String 2");
mapper.insert(record);
PkblobsExample example = new PkblobsExample();
example.createCriteria().andIdGreaterThan(4);
List<PkblobsKey> answer = mapper.selectByExample(example);
assertEquals(1, answer.size());
PkblobsKey key = answer.get(0);
assertFalse(key instanceof PkblobsWithBLOBs);
assertEquals(6, key.getId().intValue());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper in project generator by mybatis.
the class HierarchicalJava5Test method testPKBlobsSelectByExampleWithoutBlobsNoCriteria.
@Test
public void testPKBlobsSelectByExampleWithoutBlobsNoCriteria() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
PkblobsWithBLOBs record = new PkblobsWithBLOBs(3, generateRandomBlob(), generateRandomBlob(), "Long String 1");
mapper.insert(record);
record = new PkblobsWithBLOBs(6, generateRandomBlob(), generateRandomBlob(), "Long String 2");
mapper.insert(record);
PkblobsExample example = new PkblobsExample();
example.createCriteria();
List<PkblobsKey> answer = mapper.selectByExample(example);
assertEquals(2, answer.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKBlobsSelectByExampleWithMultiInsert.
@Test
public void testPKBlobsSelectByExampleWithMultiInsert() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Collection<Pkblobs> records = new ArrayList<>();
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
records.add(record);
record = new Pkblobs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
records.add(record);
int recordsInserted = mapper.insertMultiple(records);
assertEquals(2, recordsInserted);
List<Pkblobs> answer = mapper.select(dsl -> dsl.where(pkblobs.id, isGreaterThan(4)));
assertEquals(1, answer.size());
Pkblobs newRecord = answer.get(0);
assertEquals(record.getId(), newRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
}
}
use of mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKBlobscount.
@Test
public void testPKBlobscount() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new Pkblobs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
long rows = mapper.count(dsl -> dsl.where(pkblobs.id, isLessThan(4)));
assertEquals(1, rows);
rows = mapper.count(dsl -> dsl);
assertEquals(2, rows);
}
}
use of mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper in project generator by mybatis.
the class FlatJava5Test method testPKBlobsUpdateByPrimaryKeyWithBLOBs.
@Test
public void testPKBlobsUpdateByPrimaryKeyWithBLOBs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
Pkblobs record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new Pkblobs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
int rows = mapper.updateByPrimaryKeyWithBLOBs(record);
assertEquals(1, rows);
Pkblobs newRecord = mapper.selectByPrimaryKey(3);
assertNotNull(newRecord);
assertEquals(record.getId(), newRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
} finally {
sqlSession.close();
}
}
Aggregations