HHH-6972 Support PostgreSQL and Oracle LOBs
This commit is contained in:
parent
54fdb87d30
commit
500e0222b5
|
@ -111,28 +111,27 @@ public class BlobTypeDescriptor extends AbstractTypeDescriptor<Blob> {
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public <X> X unwrap(Blob value, Class<X> type, WrapperOptions options) {
|
public <X> X unwrap(Blob value, Class<X> type, WrapperOptions options) {
|
||||||
if ( ! ( Blob.class.isAssignableFrom( type ) || BinaryStream.class.isAssignableFrom( type ) ) ) {
|
|
||||||
throw unknownUnwrap( type );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( BinaryStream.class.isAssignableFrom( type ) ) {
|
|
||||||
try {
|
try {
|
||||||
|
if ( BinaryStream.class.isAssignableFrom( type ) ) {
|
||||||
return (X) new BinaryStreamImpl( DataHelper.extractBytes( value.getBinaryStream() ) );
|
return (X) new BinaryStreamImpl( DataHelper.extractBytes( value.getBinaryStream() ) );
|
||||||
}
|
} else if ( byte[].class.isAssignableFrom( type )) {
|
||||||
catch ( SQLException e ) {
|
return (X) DataHelper.extractBytes( value.getBinaryStream() );
|
||||||
throw new HibernateException( "Unable to access blob stream", e );
|
} else if (Blob.class.isAssignableFrom( type )) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
final Blob blob = WrappedBlob.class.isInstance( value )
|
final Blob blob = WrappedBlob.class.isInstance( value )
|
||||||
? ( (WrappedBlob) value ).getWrappedBlob()
|
? ( (WrappedBlob) value ).getWrappedBlob()
|
||||||
: value;
|
: value;
|
||||||
return (X) blob;
|
return (X) blob;
|
||||||
}
|
}
|
||||||
|
} catch ( SQLException e ) {
|
||||||
|
throw new HibernateException( "Unable to access blob stream", e );
|
||||||
|
}
|
||||||
|
|
||||||
|
throw unknownUnwrap( type );
|
||||||
|
}
|
||||||
|
|
||||||
public <X> Blob wrap(X value, WrapperOptions options) {
|
public <X> Blob wrap(X value, WrapperOptions options) {
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
|
|
Loading…
Reference in New Issue