Permalink
Browse files

HHH-6972 Support PostgreSQL and Oracle LOBs

  • Loading branch information...
brmeyer
brmeyer committed Sep 20, 2012
1 parent 54fdb87 commit 500e0222b59368a47c0f4b2752480dd78c89acfd
@@ -111,27 +111,26 @@ public boolean areEqual(Blob one, Blob another) {
@SuppressWarnings({ "unchecked" })
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 ) {
return null;
}
- if ( BinaryStream.class.isAssignableFrom( type ) ) {
- try {
+ try {
+ if ( BinaryStream.class.isAssignableFrom( type ) ) {
return (X) new BinaryStreamImpl( DataHelper.extractBytes( value.getBinaryStream() ) );
+ } else if ( byte[].class.isAssignableFrom( type )) {
+ return (X) DataHelper.extractBytes( value.getBinaryStream() );
+ } else if (Blob.class.isAssignableFrom( type )) {
+ final Blob blob = WrappedBlob.class.isInstance( value )
+ ? ( (WrappedBlob) value ).getWrappedBlob()
+ : value;
+ return (X) blob;
}
- catch ( SQLException e ) {
- throw new HibernateException( "Unable to access blob stream", e );
- }
+ } catch ( SQLException e ) {
+ throw new HibernateException( "Unable to access blob stream", e );
}
-
- final Blob blob = WrappedBlob.class.isInstance( value )
- ? ( (WrappedBlob) value ).getWrappedBlob()
- : value;
- return (X) blob;
+
+ throw unknownUnwrap( type );
}
public <X> Blob wrap(X value, WrapperOptions options) {

0 comments on commit 500e022

Please sign in to comment.