Permalink
Browse files

HHH-6972 Support PostgreSQL and Oracle LOBs

  • Loading branch information...
1 parent 69442c6 commit 8c58af3b194cf019dfa7bbfb0546085acb6b909e brmeyer committed Sep 19, 2012
@@ -155,29 +155,6 @@ public PostgreSQL81Dialect() {
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";
}
@@ -38,6 +38,7 @@
* Descriptor for general {@link Serializable} handling.
*
* @author Steve Ebersole
+ * @author Brett meyer
*/
public class SerializableTypeDescriptor<T extends Serializable> extends AbstractTypeDescriptor<T> {
@@ -99,30 +100,27 @@ public int extractHashCode(T value) {
public <X> X unwrap(T value, Class<X> 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 <X> 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 ) {
@@ -39,6 +39,7 @@
*
* @author Steve Ebersole
* @author Gail Badner
+ * @author Brett Meyer
*/
public abstract class BlobTypeDescriptor implements SqlTypeDescriptor {

0 comments on commit 8c58af3

Please sign in to comment.