package com.peterphi.std.guice.hibernate.dialect;

import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.type.descriptor.sql.BinaryTypeDescriptor;
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;

/**
 * A custom PostgreSQL Dialect for Hibernate that uses bytea instead of oid for byte[] Lobs
 */
public class PostgresDialect extends PostgreSQLDialect
{
	@Override
	public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)
	{
		if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB)
			return BinaryTypeDescriptor.INSTANCE;
		else
			return super.remapSqlTypeDescriptor(sqlTypeDescriptor);
	}
}

@@ -79,24 +79,26 @@
 t.PostgreSQL
+82
 Dialect;%0Aimp
@@ -365,16 +365,18 @@
 stgreSQL
+82
 Dialect%0A

Update PostgresDialect to remove use of deprecated supertype, now using PostgreSQL82Dialect