springpostgresqlhibernatehibernate-envers

Hibernate envers with postgresql sees byte array as type bytea, but i expect it to be oid


After upgrading tot spring 3 and hibernate core/envers to 6.* this issue occurs.

I have an entity with column;

@Lob
private byte[] content;

My database table has a column named content with type oid.

Since i use envers, i also have a _aud table with a column named 'content' with type oid.

While starting up the schema validation gives the following error;

Schema-validation: wrong column type encountered in column [content] in table [xxxxx_aud]; found [oid (Types#BIGINT)], but expecting [bytea (Types#VARBINARY)]

If i add @NotAudited to this field, it works, so my normal table works with type OID. I expect my hibernate envers column also to be OID, but bytea is wanted.

Do i need to convert my _aud table column content to bytea or is this a hibernate envers bug?


Solution

  • I managed to fix this by creating a custom Converter

      @Converter
      public class ContentConverter implements AttributeConverter<byte[], Blob> {
    
      //code
    
      }
    

    and added the annotation to the field;

      @Lob
      @Convert(converter = ContentConverter.class)
      private byte[] content;