SqlSession sqlSession = sqlSessionFactory.openSession();
try {
FieldsblobsMapper mapper = sqlSession
.getMapper(FieldsblobsMapper.class);
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs("Jeff",
"Smith", generateRandomBlob(), generateRandomBlob(), null);
mapper.insert(record);
record = new FieldsblobsWithBLOBs("Scott", "Jones",
generateRandomBlob(), generateRandomBlob(), null);
mapper.insert(record);
FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs(null,
"Doe", null, null, null);
FieldsblobsExample example = new FieldsblobsExample();
example.createCriteria().andFirstnameLike("S%");
int rows = mapper.updateByExampleSelective(newRecord, example);
assertEquals(1, rows);
List<FieldsblobsWithBLOBs> answer = mapper
.selectByExampleWithBLOBs(example);
assertEquals(1, answer.size());
FieldsblobsWithBLOBs returnedRecord = answer.get(0);
assertEquals(record.getFirstname(), returnedRecord.getFirstname());
assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
assertTrue(blobsAreEqual(record.getBlob1(),
returnedRecord.getBlob1()));
assertTrue(blobsAreEqual(record.getBlob2(),
returnedRecord.getBlob2()));
} finally {
sqlSession.close();
}
}