| I have a problem with hibernate and MySQL and inserting a blob. In our previous version of hibernate (3.6.0) a blob was persisted to the database with BlobTypeDescriptor.STREAM_BINDING. Now the blob is persisted with BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING. (see org.hibernate.type.descriptor.sql.BlobTypeDescriptor.DEFAULT and the doBind method) The latter uses twice (2x!) the number of bytes (I think a byte is encoded as hex) as the streaming option. In our junittest we now get the exception "com.mysql.cj.jdbc.exceptions.PacketTooBigException" I noticed that the problem doesn't exist for Clob. A provision for Clob is made in org.hibernate.dialect.Dialect. I think the same provision should be made for Blob. In Dialect.java the following code is in method Dialect.getSqlTypeDescriptorOverride(int sqlCode):
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
SqlTypeDescriptor descriptor;
switch ( sqlCode ) {
case Types.CLOB: {
descriptor = useInputStreamToInsertBlob() ? ClobTypeDescriptor.STREAM_BINDING : null;
break;
}
default: {
descriptor = null;
break;
}
}
return descriptor;
}
The method could be changed to:
protected SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) {
SqlTypeDescriptor descriptor;
switch ( sqlCode ) {
case Types.CLOB: {
descriptor = useInputStreamToInsertBlob() ? ClobTypeDescriptor.STREAM_BINDING : null;
break;
}
case Types.BLOB: {
descriptor = useInputStreamToInsertBlob() ? BlobTypeDescriptor.STREAM_BINDING : null;
break;
}
default: {
descriptor = null;
break;
}
}
return descriptor;
}
|