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:

807 questions
61
votes
3 answers

What's the difference between @NotAudited and RelationTargetAuditMode.NOT_AUDITED in Hibernate EnVers?

@NotAudited @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) @OneToMany(mappedBy = "booking") @OrderBy("bookingOrder") private List customerBookingList = new LinkedList(); Why use both? is it good to…
Phil
  • 32,917
  • 29
  • 99
  • 154
32
votes
4 answers

Hibernate Envers with Spring Boot - configuration

I'm trying to setup Hibernate Envers to work with my Spring Boot application. I've included the Envers dependency and added @Audited annotations and it works fine, but I'm unable to configure specific Envers properties, Spring Boot doesn't seem to…
Milan
  • 1,272
  • 1
  • 10
  • 25
27
votes
1 answer

How not to audit a join table and related entities using Hibernate Envers?

I use Hibernate Envers to audit my entities. I have one audited entity, Foo, which has a List as properties. However, I don't want to audit the Bar entities. Thus, I wrote that: @Entity @Audited public class Foo { @JoinTable(name =…
Romain Linsolas
  • 73,921
  • 45
  • 197
  • 265
26
votes
3 answers

Hibernate Envers: Initializing Envers Proxies

In Hibernate Envers, all related collections of an entity are loaded lazily, regardless of what fetch type is set. So when auditquerying for an entity that has a collection of other entities (both audited, of course), the collection is a SetProxy at…
Jim Holden
  • 1,156
  • 1
  • 16
  • 36
22
votes
5 answers

Populate envers revision tables with existing data from Hibernate Entities

I'm adding envers to an existing hibernate entities. Everything is working smoothly so far as far as auditing, however querying is a different issue because the revision tables aren’t populated with the existing data. Has anyone else already solved…
danieljimenez
  • 1,279
  • 4
  • 15
  • 26
17
votes
3 answers

How to manage object revisions in Grails?

I need to implement a revision system for articles in my grails web app. After searching grails forum, stackoverflow, grails plugins and googling internet, I have ended up with 3 options: Option 1 - Using the grails Envers plugin (see…
fabien7474
  • 15,395
  • 22
  • 90
  • 120
17
votes
1 answer

Hibernate Envers - Get Fields that have changed

I have a rather complicated DB structure that I am trying to audit. Currently I have Envers running and it audits the changes that are made to each object. This works really well! I now want to show some audit information on the UI. The…
RNJ
  • 14,308
  • 16
  • 73
  • 125
15
votes
3 answers

How does Envers deal with schema changes?

I am thinking about switching from a self-implemented versioning-solution to Hibernate Envers, but I am not quite sure yet. I have read a lot about it, but I am concerned about schema changes and how Envers deals with them after having historized…
15
votes
1 answer

Hibernate Envers Revert data to a version

We are using Hibernate envers to store historical revisions of the data, there is a requirement to revert data to a certain revision. As we are using the Version column to use the optimistic locking approach, when I try to save data from the…
Rakesh
  • 345
  • 3
  • 8
15
votes
1 answer

Formula mappings are currently not supported - Hibernate ORM Envers

I use Hibernate Envers: @Entity @Table(name = "user") @Audited class User() { private String id; @Formula("(SELECT name FROM other c where c.id = id)") private Integer name; } it…
Kamil Nekanowicz
  • 4,836
  • 7
  • 25
  • 46
15
votes
2 answers

Hibernate Envers: @Audited on a subclass

I have a classic inheritance persistence with entities Parent and Child, where Child extends Parent. Class Parent is abstract, while Child is not. I want to audit Child. This entity is under my control, while Parent is not. Besides, it has many…
Jose
  • 173
  • 1
  • 9
14
votes
2 answers

Hibernate Envers and "Javassist Enhancement failed" Exception

We are using Hibernate Envers and have the following situation: A class BusinessObjectType and a class Identity with a reference to BusinessObjectType: @Entity @Table( name = "ID_IDENTITY" ) @Audited public class Identity { @ManyToOne …
Matteo
  • 13,467
  • 9
  • 63
  • 103
12
votes
1 answer

hibernate-envers RevisionListener spring integration as spring bean

I need to do some database processing in revision listener of hibernate-envers. For that I need inejction capabilities of Spring Framework. How can this be implemented? Here is the code representing the need but CustomRevisionListener is…
Vyacheslav
  • 2,727
  • 4
  • 24
  • 41
12
votes
4 answers

Audit table using "Envers" in Spring Hibernate java project

We need to audit the existing table using envers. we don't have hibernate.xml instead of we are using application-context.xml. And we are creating schema through "liquibase-changeset", then how do I create through annotations like @Entity and…
SST
  • 1,496
  • 2
  • 20
  • 48
12
votes
1 answer

Can I change and how to change REVTYPE values in Hibernate Envers?

I'm new in Hiberante and Envers. I successfully implemented Hibernate Envers in my application and made audited tables and everything works fine but I'm wondering is it possible to change values in REVTYPE column in audited tables. For now I have…
snoopy_15
  • 1,073
  • 2
  • 16
  • 29
1
2 3
53 54