diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java index 716f7b9fd2..b292ec1a13 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java @@ -155,29 +155,6 @@ public class PostgreSQL81Dialect extends Dialect { getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" ); } - /** - * {@inheritDoc} - */ - @Override - public SqlTypeDescriptor getSqlTypeDescriptorOverride(int sqlCode) { - SqlTypeDescriptor descriptor; - switch ( sqlCode ) { - case Types.BLOB: { - descriptor = BlobTypeDescriptor.BLOB_BINDING; - break; - } - case Types.CLOB: { - descriptor = ClobTypeDescriptor.CLOB_BINDING; - break; - } - default: { - descriptor = super.getSqlTypeDescriptorOverride( sqlCode ); - break; - } - } - return descriptor; - } - public String getAddColumnString() { return "add column"; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java index beb4ed725e..d05d01556f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java @@ -38,6 +38,7 @@ import org.hibernate.type.descriptor.WrapperOptions; * TODO : javadoc * * @author Steve Ebersole + * @author Brett meyer */ public class SerializableTypeDescriptor extends AbstractTypeDescriptor { @@ -99,30 +100,27 @@ public class SerializableTypeDescriptor extends Abstract public X unwrap(T value, Class type, WrapperOptions options) { if ( value == null ) { return null; - } - if ( byte[].class.isAssignableFrom( type ) ) { + } else if ( byte[].class.isAssignableFrom( type ) ) { return (X) toBytes( value ); - } - if ( InputStream.class.isAssignableFrom( type ) ) { + } else if ( InputStream.class.isAssignableFrom( type ) ) { return (X) new ByteArrayInputStream( toBytes( value ) ); - } - if ( BinaryStream.class.isAssignableFrom( type ) ) { + } else if ( BinaryStream.class.isAssignableFrom( type ) ) { return (X) new BinaryStreamImpl( toBytes( value ) ); + } else if ( Blob.class.isAssignableFrom( type )) { + return (X) options.getLobCreator().createBlob( toBytes(value) ); } + throw unknownUnwrap( type ); } public T wrap(X value, WrapperOptions options) { if ( value == null ) { return null; - } - if ( byte[].class.isInstance( value ) ) { + } else if ( byte[].class.isInstance( value ) ) { return fromBytes( (byte[]) value ); - } - if ( InputStream.class.isInstance( value ) ) { + } else if ( InputStream.class.isInstance( value ) ) { return fromBytes( DataHelper.extractBytes( (InputStream) value ) ); - } - if ( Blob.class.isInstance( value )) { + } else if ( Blob.class.isInstance( value )) { try { return fromBytes( DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() ) ); } catch ( SQLException e ) { diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java index 0607b5c4f9..59d98edd18 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java @@ -37,6 +37,8 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; * Descriptor for {@link Types#BLOB BLOB} handling. * * @author Steve Ebersole + * @author Gail Badner + * @author Brett Meyer */ public abstract class BlobTypeDescriptor implements SqlTypeDescriptor {