SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsblobsMapper mapper = sqlSession
.getMapper(PkfieldsblobsMapper.class);
PkfieldsblobsWithBLOBs record = new PkfieldsblobsWithBLOBs(3, 4,
"Jeff", "Smith", generateRandomBlob());
mapper.insert(record);
record = new PkfieldsblobsWithBLOBs(5, 6, "Scott", "Jones",
generateRandomBlob());
mapper.insert(record);
PkfieldsblobsWithBLOBs newRecord = new PkfieldsblobsWithBLOBs(null,
null, "Fred", null, null);
PkfieldsblobsExample example = new PkfieldsblobsExample();
example.createCriteria().andId1NotEqualTo(3);
int rows = mapper.updateByExampleSelective(newRecord, example);
assertEquals(1, rows);
List<PkfieldsblobsWithBLOBs> answer = mapper
.selectByExampleWithBLOBs(example);
assertEquals(1, answer.size());
PkfieldsblobsWithBLOBs returnedRecord = answer.get(0);
assertEquals(record.getId1(), returnedRecord.getId1());
assertEquals(record.getId2(), returnedRecord.getId2());
assertEquals(newRecord.getFirstname(),
returnedRecord.getFirstname());
assertEquals(record.getLastname(), returnedRecord.getLastname());
assertTrue(blobsAreEqual(record.getBlob1(),
returnedRecord.getBlob1()));
} finally {
sqlSession.close();
}
}