@@ -0,0 +1,653 @@
+package com.peterphi.std.guice.hibernate.dialect;%0A%0Aimport org.hibernate.dialect.PostgreSQLDialect;%0Aimport org.hibernate.type.descriptor.sql.BinaryTypeDescriptor;%0Aimport org.hibernate.type.descriptor.sql.SqlTypeDescriptor;%0A%0A/**%0A * A custom PostgreSQL Dialect for Hibernate that uses bytea instead of oid for byte%5B%5D Lobs%0A */%0Apublic class PostgresDialect extends PostgreSQLDialect%0A%7B%0A%09@Override%0A%09public SqlTypeDescriptor remapSqlTypeDescriptor(SqlTypeDescriptor sqlTypeDescriptor)%0A%09%7B%0A%09%09if (sqlTypeDescriptor.getSqlType() == java.sql.Types.BLOB)%0A%09%09%09return BinaryTypeDescriptor.INSTANCE;%0A%09%09else%0A%09%09%09return super.remapSqlTypeDescriptor(sqlTypeDescriptor);%0A%09%7D%0A%7D%0A

Add new postgres dialect so @Lob byte[] works with bytea columns (Hibernate was using oid) using approach in http://stackoverflow.com/a/22182893/265237