5

We are using Envers with both Oracle and MySQL without any problem. We are now trying PostgreSQL but we have the problem that the audit tables are created with a column REVTYPE of type TINYINT.

TINYINT is not supported by PostgreSQL.

Is there a way to change the type of REVTYPE?

Example:

create table AUD_SomeTable (
  dbId bigint not null,
  ...
  REV integer not null,
  REVTYPE tinyint,
  primary key (dbId, REV)
);

EDIT:

Problem solved: I forgot the change the Hibernate dialect.

Matteo
  • 14,696
  • 9
  • 68
  • 106

2 Answers2

3

You should test whether this is really an Envers issue or an Hibernate issue. Try mapping an entity with a property byte type using hibernate only. If it tries to generate a tinyint column it would be a Hibernate issue.

A.H.
  • 63,967
  • 15
  • 92
  • 126
  • It was a configuration issue. Specifying the correct Hibernate dialect solved the problem. – Matteo Feb 22 '12 at 15:03
  • @Matteo Which dialect did you use? – conscience Sep 06 '16 at 14:58
  • @Matteo thanks for the quick answer :) Do you have any idea how to fix the issue nowadays? I just ran into the same issue with hibernate envers, flyway and postgres – conscience Sep 06 '16 at 15:17
  • Hi I just want to quickly link another post regarding this issue: [link](http://stackoverflow.com/questions/35925228/hibernate-entity-auditing-and-hbm2ddl-auto-validate-in-h2-and-oracle) ... Now my validation works and I can still use a h2 database. – conscience Sep 08 '16 at 10:19
2

I don't know about about Envers, but you could create a new domain type.

CREATE DOMAIN "tinyint"
  AS smallint;

You can add CONSTRAINS to check for e.g. a postive value.

DrColossos
  • 12,656
  • 3
  • 46
  • 67
  • 1
    Thanks for the answer: this works but I noticed that I just forgot to change the Hibernate dialect setting ... – Matteo Feb 22 '12 at 14:30