public static final FixedBlobTypeDescriptor STREAM_BINDING = new FixedBlobTypeDescriptor() {
@Override
public <X> FixedBasicBinder<X> getBlobBinder(final JavaTypeDescriptor<X> javaTypeDescriptor) {
return new FixedBasicBinder<X>(javaTypeDescriptor, this) {
@Override
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
final BinaryStream binaryStream = javaTypeDescriptor.unwrap(
value,
BinaryStream.class,
options
);
long length = binaryStream.getLength();
if (length <= Integer.MAX_VALUE) {
st.setBinaryStream(index, binaryStream.getInputStream(), (int) length);
}
else {
st.setBinaryStream(index, binaryStream.getInputStream(), length);
}
}
};
}
};