Questions tagged [hibernate-envers]

Hibernate Envers is a core module of the Hibernate framework that enables simple entity auditing and change tracking using annotations and simple configuration steps.

Hibernate Envers is a core module of Hibernate.

Envers provides simple entity auditing and change tracking by using Java annotations to influence what it to be tracked by the change management listeners. The module allows you to save historical changes (CRUD operations) made on your persistent entities in audit specific tables that are created by Envers automatically.

Official site:
http://www.hibernate.org/orm/envers

To take advantage of Hibernate Envers, you first need to add the dependency. You simply need to configure the dependency as follows:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-envers</artifactId>
  <version>5.2.8.Final</version>
</dependency>

It's important to remember that the version of Envers you should use must match the same version of Hibernate that your application is using.

A Simple Example

@Entity
@Audited
public class Person {
  @Id
  private Integer id;
  private String name;
  private Date dateOfBirth;
  // getter/setters
}

Guides And Tutorials:

883 questions
5
votes
2 answers

While doing delete operation few fields are not audited its take value as null while persisting in db

Using Hibernate Envers, while doing create operation audit functionality is properly working data is correctly filled up in main as well as audit table but while deleting an entry for few fields its taking null following is the code…
aeroboy
  • 149
  • 4
  • 14
5
votes
1 answer

Hibernate Envers - show differences between revisions

Following up by these three topics: Getting the old value and new value between two revisions with Hibernate Envers Diff on hibernate envers revisions Hibernate Envers : How to check if a field has changed between two revisions? I am looking for…
bontade
  • 3,194
  • 6
  • 48
  • 75
5
votes
1 answer

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…
kenn3th
  • 1,187
  • 2
  • 22
  • 47
5
votes
1 answer

Envers: How to add a new column in *_AUD table (not in REVINFO table)

For each audited entity, envers create a table with *_AUD suffix. Each table has TWO extra columns ( REV and revtype). I just want to dynamically create a new one column to fulfill my extra needs. Obs: Manually create the new column as a new filed…
CelinHC
  • 1,857
  • 2
  • 27
  • 36
5
votes
1 answer

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?
AppSensei
  • 8,270
  • 22
  • 71
  • 99
5
votes
1 answer

How to get row count of audit table using hibernate envers

In audit table, there is not such a Criteria that we could use Criteria.setProjection(Projections.rowCount()) to get the row count of the query. We could use AuditQuery to do similar things. But I couldn't find how to set projections in this case.…
5
votes
2 answers

Querying all Hibernate Envers revisions between two dates

I have just started using Hibernate Envers for audit, and i will like to know if there is a way to get all the revisions of a class between two dates. up until now i was using: AuditQuery query =…
PearlJam
  • 51
  • 1
  • 2
5
votes
1 answer

Auditing with Envers and Hibernate Spatial 4

I'm attempting to use Envers to set up Auditing on my Hibernate entities. However, I'm getting the error: Could not determine type for: geometry, at table: Location_AUD, for columns: [org.hibernate.mapping.Column(geom)] Hibernate is happy with the…
5
votes
4 answers

Audit and data history in java

I have a set of domain objects and its related tables for application's configurations. Authenticated users can change these domain objects data thru a presentation layer. These domain objects have very important data and I need find who and when…
Sam
  • 6,770
  • 7
  • 50
  • 91
4
votes
1 answer

Envers - How to propagate change of child-entity to parent?

I've got the following setup: @Entity @Audited public class House { @OneToOne(cascade = CascadeType.ALL) private Door frontDoor; // ... } @Entity @Audited public class Door { private String color; // ... } and then…
leun4m
  • 560
  • 5
  • 24
4
votes
1 answer

Missing properties in Envers auditing tables

I am using envers to audit my ParameterToValue entity. Its properties "containerId", "containerType", "parameterId" which do appear as columns in a mapped DB table "values_for_params" (a regular Hibernate table), are missing at the envers generated…
AndreyKo
  • 901
  • 7
  • 16
4
votes
1 answer

Hibernate Envers: Audit Reader throws LazyInitializationException when trying to get revision history

I successfully configured Hibernate Envers entities I want to audit, but when I try to get audit history using Audit Reader I get java.lang.NoSuchMethodError. Code snippets is shown below. Domain model…
4
votes
2 answers

How to create Audit Tables automaticcaly without using spring.jpa.hibernate.ddl-auto using Spring Hibernate

I need to create Audit tables automatically when I saved to a table. I added "org.hibernate:hibernate-envers:5.4.2". Final to my gradle file and annotated the Entity using @Audited. I cannot use "spring.jpa.hibernate.ddl-auto" in my application…
user9353766
  • 75
  • 12
4
votes
1 answer

Envers audit table does not rollback in spring-boot integration tests annotated with @Transactional

I am trying to figure out why @Transactional does not rollback data in envers audit table after each test and how to fix it. How can I make that happen in spring integration tests? I have tried with @DirtiesContext and that makes it work but it's…
4
votes
0 answers

What is envers @AuditMappedBy() supposed to do?

I am using Hibernate-Envers 4.3.11 Final I see that the documentation says: To properly audit such relations with Envers, you can use the @AuditMappedBy annotation. It enables you to specify the reverse property (using the mappedBy element).…
Joey Corkey
  • 475
  • 1
  • 6
  • 19