Skip to content
Browse files

HHH-6972 Support PostgreSQL and Oracle LOBs

  • Loading branch information...
1 parent 068c973 commit 8dbaefced41dfa17aa7681dcd0ae002ec039e1a1 brmeyer committed Sep 26, 2012
Showing with 27 additions and 0 deletions.
  1. +27 −0 hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java
View
27 hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java
@@ -155,6 +155,33 @@ public PostgreSQL81Dialect() {
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";
}

0 comments on commit 8dbaefc

Please sign in to comment.
Something went wrong with that request. Please try again.