Hibernate, Postgresql: Column "x" is of type oid but expression is of type byte

This field mapping is defined in org.hibernate.dialect.PostgreSQLDialect and can be changed by subclassing this and configuring your app to use the modified dialect when running with postgres.

The relevant incantation in the subclass is probably to put

    registerColumnType( Types.BLOB, "bytea" );

in your constructor after a call to super().


The class is deprecated since Hibernate 3.6. Now with latest Hibernate we need to use @Type(type="org.hibernate.type.MaterializedBlobType") instead. Please check https://docs.jboss.org/hibernate/core/3.6/javadocs/deprecated-list.html and https://docs.jboss.org/hibernate/core/3.6/javadocs/org/hibernate/type/MaterializedBlobType.html for more information.


For me this may have meant once "revert your postgres jdbc version back down to 9.3-1101.jdbc4"

  <dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>9.4-1200-jdbc41</version>
  </dependency>

worked as well. Newer than that failed...