BlobTestPeer.doDelete(criteria);
}
// create a new BlobTest Object with large blob and clob values
// and save it
BlobTest blobTest = new BlobTest();
{
int length = 100000;
byte[] bytes = new byte[length];
StringBuffer chars = new StringBuffer();
String charTemplate = "1234567890abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < length; ++i)
{
bytes[i] = new Integer(i % 256).byteValue();
chars.append(charTemplate.charAt(i % charTemplate.length()));
}
blobTest.setBlobValue(bytes);
}
blobTest.save();
// read the BlobTests from the database
// and check the values against the original values
List blobTestList = BlobTestPeer.doSelect(new Criteria());
assertTrue("blobTestList should contain 1 object but contains "
+ blobTestList.size(),
blobTestList.size() == 1);
BlobTest readBlobTest = (BlobTest) blobTestList.get(0);
assertTrue("read and written blobs should be equal. "
+ "Size of read blob is"
+ readBlobTest.getBlobValue().length
+ " size of written blob is "
+ blobTest.getBlobValue().length,
Arrays.equals(
blobTest.getBlobValue(),
readBlobTest.getBlobValue()));
}