Hi -
I use Hibernate 2.1.2, Tomcat 4.1.29, mysql 4 and mapped a
blob to byte[] as descibed in
http://www.hibernate.org/73.html using a UserType.
In my application I have 2 blob columns in the database. I read the first column (a thumbnail), convert it and try to write it back to the second column.
However, I get an exception in method nullSafeSet of the UserType when
the session is flushed:
net.sf.hibernate.lob.BlobImpl.excep(BlobImpl.java:95)
at net.sf.hibernate.lob.BlobImpl.getBytes(BlobImpl.java:48)
at com.mysql.jdbc.PreparedStatement.setBlob(PreparedStatement.java:358)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:260)
at MyBinaryBlob.nullSafeSet(BinaryBlob.java:57)
For nullSafeSet I tried
public void nullSafeSet(PreparedStatement st, Object value, int index)
throws HibernateException, SQLException
{
if (value!=null) {
Blob b=new BlobImpl((byte[])value);
st.setBlob(index, b);
}
}
and alternatively
st.setBlob(index, Hibernate.createBlob((byte[]) value));
isMutable() returns true.
Thank you for any solution hint -
Christian