From 8dbaefced41dfa17aa7681dcd0ae002ec039e1a1 Mon Sep 17 00:00:00 2001 From: brmeyer Date: Wed, 26 Sep 2012 17:33:54 -0400 Subject: [PATCH] HHH-6972 Support PostgreSQL and Oracle LOBs --- .../dialect/PostgreSQL81Dialect.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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 b292ec1a13..b3d36326d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java @@ -155,6 +155,33 @@ 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: { + // Force BLOB binding. Otherwise, byte[] fields annotated + // with @Lob will attempt to use + // BlobTypeDescriptor.PRIMITIVE_ARRAY_BINDING. Since the + // dialect uses oid for Blobs, byte arrays cannot be used. + 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"; }