Hi:
I am using Hibernate 2.1 with Oracle 8i. I am using following code to save blobs.
childData.setFullAnswer(Hibernate.createBlob(" ".getBytes()));
//end blob code
serviceImpl.getSession().saveOrUpdateCopy(childData);
//blob code
serviceImpl.getSession().flush();
serviceImpl.getSession().refresh(childData, LockMode.UPGRADE);
BLOB blob = (BLOB)childData.getFullAnswer();
OutputStream os = null;
try
{
os = blob.getBinaryOutputStream();
}
catch (SQLException e)
{
e.printStackTrace();
}
if (os != null) {
byte[] b = childData.getAnswer().getBytes();
if (childData.getAnswer() != null) os.write(b); else os.write(null);
os.flush();
os.close();
}
When I check in database, only 1 byte is saved. There is no exception or error. Your help will be sincerely appreciated.
|