use of mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsKey in project generator by mybatis.
the class HierarchicalJava5Test method testPKBlobsUpdateByPrimaryKeySelective.
@Test
public void testPKBlobsUpdateByPrimaryKeySelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
PkblobsWithBLOBs record = new PkblobsWithBLOBs();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
PkblobsWithBLOBs newRecord = new PkblobsWithBLOBs();
newRecord.setId(3);
newRecord.setBlob2(generateRandomBlob());
mapper.updateByPrimaryKeySelective(newRecord);
PkblobsKey key = new PkblobsKey();
key.setId(3);
PkblobsWithBLOBs returnedRecord = mapper.selectByPrimaryKey(key);
assertNotNull(returnedRecord);
assertEquals(record.getId(), returnedRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
assertTrue(blobsAreEqual(newRecord.getBlob2(), returnedRecord.getBlob2()));
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsKey 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();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new PkblobsWithBLOBs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
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.hierarchical.immutable.model.PkblobsKey in project generator by mybatis.
the class HierarchicalJava5Test method testPKBlobsUpdateByPrimaryKeySelective.
@Test
public void testPKBlobsUpdateByPrimaryKeySelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
PkblobsWithBLOBs record = new PkblobsWithBLOBs(3, generateRandomBlob(), generateRandomBlob(), "Long String 1");
mapper.insert(record);
PkblobsWithBLOBs newRecord = new PkblobsWithBLOBs(3, null, generateRandomBlob(), "Long String 2");
mapper.updateByPrimaryKeySelective(newRecord);
PkblobsKey key = new PkblobsKey(3);
PkblobsWithBLOBs returnedRecord = mapper.selectByPrimaryKey(key);
assertNotNull(returnedRecord);
assertEquals(record.getId(), returnedRecord.getId());
assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
assertTrue(blobsAreEqual(newRecord.getBlob2(), returnedRecord.getBlob2()));
assertEquals(newRecord.getCharacterlob(), returnedRecord.getCharacterlob());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsKey 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.hierarchical.immutable.model.PkblobsKey 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();
record.setId(3);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
record = new PkblobsWithBLOBs();
record.setId(6);
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
mapper.insert(record);
PkblobsExample example = new PkblobsExample();
example.createCriteria();
List<PkblobsKey> answer = mapper.selectByExample(example);
assertEquals(2, answer.size());
} finally {
sqlSession.close();
}
}
Aggregations