According to
here (line 362) (and in accordance with the bug i'm facing) the implementation of org.hibernate.Hibernate.createBlob( InputStream in ) looks like this
Code:
public static Blob createBlob(InputStream stream) throws IOException {
return new SerializableBlob( new BlobImpl( stream, stream.available() ) );
}
The second parameter here is supposed to be the length of the inputstream. The problem is that stream.available() doesn't return the length of the inputstream. That's explicitly noted in the
API:
java.io.InputStream.available() wrote:
Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.
This is the source of my problem, only the first available bytes are read out of the inputstream. While the workaround for me is to simply call org.hibernate.Hibernate.createBlob( InputStream in,int length ), the misuse of stream.available() in Hibernate.createBlob( InputStream in ) remains to be resolved.