Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually create an audit table for Hibernate Envers

I understand Envers generates a table to store the audit trail. Is it possible to manually assign a table where I want the data to be stored. Instead of allowing Envers to generate a table by itself?

like image 905
AppSensei Avatar asked Dec 24 '14 12:12

AppSensei


People also ask

What is Revinfo table?

Additionaly, there is a "REVINFO" table generated, which contains only two fields: the revision id and revision timestamp. A row is inserted into this table on each new revision, that is, on each commit of a transaction, which changes audited data.

How do I enable JPA auditing?

Enable JpaAudit In order to enable JPA Auditing for this project will need to apply three annotations and a configuration class. Those annotations are; @EntityListener , @CreatedDate , and @LastModifiedDate . @EntityListener will be the one that is responsible to listen to any create or update activity.


1 Answers

It will only generate the tables if you are using one of the ddl auto options.

If you want to control the naming of the audit tables during this process or, create the tables yourself and have them named differently then you specify the value for the @AuditTable annotation and/or specify the prefix and suffix in the configuration.

Additionally, you can control/specify the name of the global REVINFO table using the @RevisionEntity annotation.

http://docs.jboss.org/envers/docs/#tables

All of which is detailed in the comprehensive documentation:

http://docs.jboss.org/envers/docs/#tables

like image 106
Alan Hay Avatar answered Oct 29 '22 17:10

Alan Hay