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
8
votes
1 answer

envers multi level entity revision howto

User have n Contacts. A Contact can have a localized Comment (Comments are shared between Contacts). Java Beans: @Audited @Entity public class User { @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, …
8
votes
1 answer

Creating Envers custom revision entity

I'm trying to setup audit for our project. I started from the default configuration which works fine. The next step is to store the user which has made changes. Following the manual I created custom entity revision: package…
Vyacheslav
  • 3,134
  • 8
  • 28
  • 42
8
votes
1 answer

Get complete Envers revisions where a particular object is affected

The way revision data is stored each object affected by a revision gets a separate record in the _AUD table. So when I search for revisions affecting object A, I will get back the entry where revision is 3 for object B, but if objects A and/or C…
Brad Mace
  • 27,194
  • 17
  • 102
  • 148
8
votes
0 answers

Hibernate Envers 4 not auditing entities

I'm using Hibernate Envers 4.1.0 + Spring 3.1.0 on my application running on Wildfly 9.0.2. Whenever I insert or update a entity it persists the entity just fine but Envers does not persist a new rev on my AUD tables. I'm searching for quiet a while…
ygorazevedo
  • 487
  • 1
  • 4
  • 14
8
votes
4 answers

Testing Hibernate Envers

I would like to write tests about revision. In the console I see the update call of Hibernate, BUT no insertions into AUD-Table. Test-Method: @DataJpaTest class JPAHistoryTest { @Test public void test() { def entity = // create…
Michael Hegner
  • 5,555
  • 9
  • 38
  • 64
8
votes
1 answer

Hibernate Envers : get only changed fields

How can i get only modified fields from audited entity? When i use AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(MyEntity.class, revisionNumber).getResultList() I get all fields; but i want to get only fields modified?
Melek ELLOUZE
  • 83
  • 1
  • 1
  • 3
8
votes
1 answer

Spring Data Envers org.springframework.data.mapping.PropertyReferenceException: No property findRevisions found for type

I have a Spring boot 1.4.2 application with Hibernate 5.2.6 and Spring data Envers 1.0.5. I am auditing my entities and the audit records are persisted properly. My application config class is annotated to use the…
8
votes
5 answers

Hibernate Envers fails with @Converter and AttributeConverter (JPA 2.1)

I am using Hibernate 4.3.4 with Envers, and MySql 5.6. Without a JPA 2.1 converter, the Party entity below fails at Configuration.buildSessionFactory() as it should, since Hibernate doesn't know what to do with the Name…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
8
votes
2 answers

Envers: Unidirectional OneToMany without additional audit table?

The following database schema: Employee[EMP_ID (PK), name, salary] Phone[ID (PK), number_str, OWNER_ID (FK)] Employee_aud[EMP_ID (PK), REV (PK/FK), REVTYPE, name, salary] Phone_aud[ID (PK), REV (PK/FK), REVTYPE,…
Andreas Aumayr
  • 1,006
  • 1
  • 11
  • 17
8
votes
1 answer

Auditing collection of @Embeddables with overridden equals/hashCode in JPA2/Hibernate

I have a setting of JPA2/Hibernate. Furthermore, the entities are audited by Hibernate Envers. I have the following class to signify postal codes with only one field, namely value. It all works fine when saving only one instance of any postal code…
RJo
  • 15,631
  • 5
  • 32
  • 63
8
votes
3 answers

Hibernate/Envers unable to read the mapped by attribute

I am unable to implement many-to-many relation using join table (https://stackoverflow.com/a/7603036 & https://en.wikibooks.org/wiki/Java_Persistence/ManyToMany#Mapping_a_Join_Table_with_Additional_Columns). When I try to reproduce it persistence…
sami
  • 81
  • 1
  • 5
8
votes
1 answer

Can i use only one table for all hibernate envers auditing?

i recently found the beautiful library that is called "hibernate envers", it's such a great and easy way to have an audit log, it solved one of my biggest problem while working on a play web-application. Now, i know that Envers use one table for…
7
votes
2 answers

Spring Boot 2 - disable Envers

How can I disable Hibernate Envers in Spring Boot 2? I don't want to remove the dependency, because the code relies on it depending on the environment. I tried the following properties in my application.properties but none worked. On startup it…
Daniel
  • 834
  • 1
  • 9
  • 25
7
votes
1 answer

Hibernate Envers: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)

In my java app I am using Hibernate Envers to listen for persist events. My listener class looks like this. @Component public class DataCreationListener extends EnversPostInsertEventListenerImpl { private static final long serialVersionUID =…
varunkr
  • 5,364
  • 11
  • 50
  • 99
7
votes
3 answers

How to get rid of "HHH90000003: Use of DOM4J entity-mode is considered deprecated"

I just upgraded my project's hibernate version to 5.0.0.FINAL. But than I realise that, I am getting this warning. And I want to get rid of it. I don't know if it will effect my application or not. 2015-08-24 14:29:22.235 WARN --- [ …
bhdrkn
  • 6,244
  • 5
  • 35
  • 42
1 2
3
58 59