I'm using 6.3.0 and enabled Envers for auditing purposes.
I run into an issue when inserting an item to the database which is Envers related.
Caused by: org.postgresql.util.PSQLException: ERROR: index row size 4624 exceeds btree version 4 maximum 2704 for index "cm_cm_property_name_values_aud_pkey" Detail: Index row references tuple (0,17) in relation "cm_cm_property_name_values_aud". Hint: Values larger than 1/3 of a buffer page cannot be indexed. Consider a function index of an MD5 hash of the value, or use full text indexing.
It looks like this is caused by the primary key being too large.
The table for which the audit table was generated looks like:
create table cm_property_name_values (
cm_property_id uuid not null,
cm_value text,
cm_name varchar(255) not null,
primary key (cm_property_id, cm_name)
);
The tables and audit tables were generated by org.hibernate.tool.hbm2ddl.SchemaExport
The generated audit table looks as follows:
create table cm_cm_property_name_values_aud (
cm_rev integer not null,
cm_cm_property_id uuid not null,
cm_cm_value text not null,
cm_cm_name varchar(255) not null,
cm_revtype smallint,
primary key (cm_cm_property_id, cm_rev, cm_cm_value, cm_cm_name)
);
The primary key looks like a combination of all fields. Since cm_cm_value is a large text field, Postgres complains that the index is too large.
According to the Hibernate documentation, the primary key should be
The primary key of the audit table is the combination of the original id of the entity and the revision number...
Any idea why the primary key is generated using all fields?
Is it possible to change the way the primary key for the audit table is created?