Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Envers rev column data type is Integer

I am using Hibernate Envers in my application to store audit trail data, all audit related information are storing in *_AUD table correctly. However, the data type of rev column in all _AUD table is Integer data type. I am expecting a big int data type because the maximum range of integer data type is 2147483647. Is there a way to change the data type to big int?

like image 688
kenn3th Avatar asked Jul 26 '16 11:07

kenn3th


1 Answers

By default, the Envers implementation uses an Integer data type for the REV column.

In order to leverage a Long data type, you'll need to supply a custom revision entity with the appropriate annotations. Below is an example that will replace the existing default implementation while using a BIGINT compatible REV column.

@Entity
@RevisionEntity
public class CustomRevisionEntity implements Serializable {
  @Id
  @GeneratedValue
  @RevisionNumber
  private Long rev;
  @RevisionTimestamp
  private Long timestamp;
  /* provide getter/setters */
}

NOTE: All audit tables will make their REV column's data type match that of the data type you use in the revision entity class.

There is an open JIRA HHH-6615 to migrate the default implementations to use Long instead of Integer based revisions; however, it does require that we consider upgrade paths as a implementation detail of that issue to account for existing users.

Until then, using a custom revision entity for new implementations is a workaround.

like image 168
Naros Avatar answered Sep 21 '22 23:09

Naros