assertEquals(clobObj2.getClobCol(), clobObj3.getClobCol());
}
protected void runWithClobSize(int sizeBytes) throws Exception {
// insert new clob
ClobTestEntity clobObj1 = ctxt.newObject(ClobTestEntity.class);
// init CLOB of a specified size
if (sizeBytes == 0) {
clobObj1.setClobCol("");
}
else {
byte[] bytes = new byte[sizeBytes];
for (int i = 0; i < sizeBytes; i++) {
bytes[i] = (byte) (65 + (50 + i) % 50);
}
clobObj1.setClobCol(new String(bytes));
}
ctxt.commitChanges();
// read the CLOB in the new context
DataContext ctxt2 = createDataContext();
List<?> objects2 = ctxt2.performQuery(new SelectQuery(ClobTestEntity.class));
assertEquals(1, objects2.size());
ClobTestEntity clobObj2 = (ClobTestEntity) objects2.get(0);
assertEquals(clobObj1.getClobCol(), clobObj2.getClobCol());
// update and save Clob
clobObj2.setClobCol("updated rather small clob...");
ctxt2.commitChanges();
// read into yet another context and check for changes
DataContext ctxt3 = createDataContext();
List<?> objects3 = ctxt3.performQuery(new SelectQuery(ClobTestEntity.class));
assertEquals(1, objects3.size());
ClobTestEntity clobObj3 = (ClobTestEntity) objects3.get(0);
assertEquals(clobObj2.getClobCol(), clobObj3.getClobCol());
}