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
Filter by
Sorted by
Tagged with
0 votes
0 answers
6 views

Hibernate Envers: Error at Update Spring Boot 2.7 to Spring Boot 3.2

I have a working Application with Spring Boot 2.7 & Hibernate & Hibernate-Envers. When i upgrade to Spring Boot 3.2 i get problems with Hibernate-Envers. I get the following error: org....
-1 votes
0 answers
47 views

Is there any way to use Hibernate Envers with custom queries

i wanted to ask if there is a way to use custom queries for lookup of revisioned entities. The reason is that i want to be in full control of when my entities are loaded and sometimes i also have some ...
0 votes
2 answers
788 views

Spring boot 3 + Envers

I am migrating an application to Spring Boot 3 that uses Hibernate Envers with @Audited annotations. But I cannot find Spring Data Envers after version 2.7 which go to end of support. https://spring....
1 vote
3 answers
1k views

How to configure Envers with @OneToMany and @EmbeddedId on the Many side

I have a User entity and a UserCompanyRole entity. The UserCompanyRole has a composite primary key. Each User can have multiple roles. I know composite primary keys should be avoided and I have ...
75 votes
3 answers
47k views

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<CustomerBooking> customerBookingList = new ...
0 votes
0 answers
10 views

Hibernate Envers throws "A different object with the same identifier value was already associated with the session" on new entity(id exists) save

id is generated and set beforehand manually for a new entity, then I use repo's save method to save it but it throws exception: org.springframework.transaction.HeuristicCompletionException, message=...
0 votes
0 answers
49 views

@MappedSuperClass with @Audited working yet causing an error

I've found that there are a number of entity classes that use the same primary key id type. For example, @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; //... ...
9 votes
2 answers
3k views

How to track delete events with Spring Data JPA auditing and Envers? [duplicate]

In my audited entity I have last modified fields: @LastModifiedBy private String lastModifiedBy; @LastModifiedDate private OffsetDateTime lastModifiedDate; But they doesn't change when entity is ...
1 vote
0 answers
393 views

Envers Audit table does not copy created_at, modified_at data

I use Spring Boot, JPA and Hibernate/Envers to get some audit logging going. Tables are setup and Envers is working - but not for all fields. In every _aud table the auto-generated fields created_at ...
1 vote
1 answer
2k views

Hibernate - Unable to perform beforeTransactionCompletion callback: Cannot read the array length because "array" is null

I got the error below after upgrading Spring Boot from version 2.7.14 to 3.1.2. Caused by: org.hibernate.HibernateException: Unable to perform beforeTransactionCompletion callback: Cannot read the ...
1 vote
2 answers
662 views

Hibernate Envers : How to inject SecurityContext (REST) in RevisionListener?

I have a REST API (using wildfly 20 with microprofile-jwt) so I would like to audit changes with Hibernate Envers. Unfortunately I can't get my Principal object : the javax.ws.rs.core.SecurityContext ...
1 vote
0 answers
60 views

Impossible to inject the SecurityContext in Quarkus 3.6.5+

Latery I'm trying to resolve a problem with my jakarta.ws.rs.core.SecurityContext. I'm using the Hibernate Envers and I have a audited entity named Movie. For hold the SecurityContext, I've adopted a ...
1 vote
1 answer
140 views

Envers and Hibernate 6.3.1 does not audit fields with annotation @Column(insertable = false, updatable = false)

We have an entity definition with following property: @Generated(GenerationTime.INSERT) @Column(insertable = false, updatable = false) private Integer number; The entity is annotated with @Audited. ...
1 vote
1 answer
135 views

After spring hibernate envers update SQLIntegrityConstraintViolationException

I have updated my spring boot from 2.0.2 to 3.0.0 (in multiple steps) and my hibernate dependencies: hibernate-envers: 5.3.20 --> 6.0.0.Final hibernate-entitymanager: 5.3.20.Final --> 6.0.0....
11 votes
2 answers
2k views

Hibernate Envers 6.4.1: Illegal argument on static metamodel field injection

I migrate to Hibernate 6.4.1 (via spring boot 3.2.1) and my app logs an error that wasnt' there before: 2024-01-03T15:49:10.361+01:00 ERROR 81857 --- [ main] o.h.metamodel.internal....
2 votes
0 answers
139 views

Cannot invoke "org.hibernate.envers.internal.entities.EntityConfiguration.getRelationDescription(String)" because "entCfg" is null

I'm migrating from Hibernate Envers 5.x to 6. In my project there are a few entities with many-to-many relationships, the junction tables are represented with entities, having a few additional fields. ...
0 votes
0 answers
37 views

How to add some costom columns and set custom values in Audit table while saved AuditedEntity?

I used spring data envers in the project and added the @Audited annotation to the entity class to audit all fields. Now, I want to extend some fields in the audit table to store additional information....
0 votes
1 answer
295 views

Find newest Revisions of Entities where timestamp is less than x

I have a max timestamp that I pass to my backend and I want to return the newest versions of the Entities that have a timestamp that is less than the passed one. The passed timestamp in my example is ...
3 votes
2 answers
293 views

Hibernate envers with postgresql sees byte array as type bytea, but i expect it to be oid

After upgrading tot spring 3 and hibernate core/envers to 6.* this issue occurs. Spring Boot version 3.1.4 Hibernate core and envers version 6.2.5.Final (tried different versions) PostgreSQL jdbc ...
-1 votes
1 answer
435 views

Accessing Envers Revisions in SpringBoot 3/Hibernate 6 using multiple Instances

In SpringBoot 3 (Hibernate 6) there was a change in which sequence generators are now allocating more than a single increment. This also applys to Envers Revision Numbers. Defaults for implicit ...
2 votes
0 answers
59 views

Hibernate Envers implementation of custom composite type

I'm trying to audit my custom Postgres type with Hibernate Envers, also I'm using Quarkus with Kotlin and panache repository. My Postgres setup: CREATE TYPE money_and_currency AS (amount integer, ...
0 votes
0 answers
29 views

Hibernate envers, audit history returns strange structure

I have 2 classes related with relation as below: @Audited(withModifiedFlag = true) @Builder @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Entity @Table(name = "number_series") ...
0 votes
0 answers
85 views

Hibernate 6.2 envers classcastexception BasicValue to Component

Hi all I have spent days trying to figure out this error. I am upgrading from hibernate 5.5.3 to hibernate 6.2.16. On start up and deploy my ear file to Wildfly 29 this is the error I get: Caused by:...
0 votes
0 answers
40 views

Hibernate Envers audit table primary key unexpected format

I'm using 6.3.0 and enabled Envers for auditing purposes. I run into an issue when inserting an item to the database which is Envers related. Caused by: org.postgresql.util.PSQLException: ERROR: index ...
8 votes
2 answers
5k views

Hibernate Envers: How to capture who deleted an entity in audit table

I am using hibernate-envers with spring. Everything works just fine, except when I delete an entity, it does not change the values of updated_by and updated_date inside audit table, instead it saves ...
0 votes
1 answer
69 views

Hibernate Envers inserts same revision into two audit records in same transaction

I have problem, becouse while same transaction I want to insert new order Entity, and delete another as below. @Transactional public void execute(OrderEntity orderToRenew) { OrderEntity ...
0 votes
1 answer
2k views

Hibernate Envers conditional auditing, custom EnversIntegrator ignored at runtime

I need to configure conditional auditing using Hibernate Envers and Spring. The default configuration works, but I want only the delete operations to be audited, saving the deleted entity in the ...
0 votes
0 answers
183 views

Hibernate-sequence generates duplicate keys when using hibernate envers

I am using hibernate envers 5.6.9.final with spring boot 2.7.2. my problem is that hibernate_sequence sometimes generates duplicates value when it needs to insert a new record in revisionInfo tabel. ...
0 votes
1 answer
60 views

Is there a way to prevent Hibernate envers to audit a database operation only once?

Stack: spring boot 2.7.15 spring-boot-starter-data-jpa 2.7.15 spring-data-envers 2.7.15 I have the following entity: @Audited @Entity @EntityListeners(AuditingEntityListener.class) public class ...
0 votes
0 answers
16 views

When auditing a map of child entities as values with Hibernate Envers, the child audit data got deleted

We use Hibernate 5.6. We have two entities: A and B, B is OneToMany mapped to A as a value of a map; and four tables used for the child and auditing. @Entity @Audited public class A { private ...
0 votes
1 answer
283 views

Unable to retrieve the revision number for an entity with spring-data-envers findLastChangeRevision

Am trying to get the revision number using the findLastChangeRevision method in spring-data-envers. Am able to fetch the last entity but the revision is alwaysUNKNOWN. And the revision number and ...
0 votes
1 answer
139 views

Envers with Hibernate Multi Tenant

I have a project that i am migrating to use hibernate multitenancy feature. So far, i am injecting the EntityManager like this @Inject protected EntityManager em; With a producer method that looks ...
0 votes
0 answers
37 views

Audit of 1 entity with 3 relationships causes error

I am auditing an entity called Form, it has a relationship with two other entities, but the method it implements is annotated with transactional, thus reviewing only one entity, if I remove the ...
1 vote
2 answers
9k views

envers audit table name

I have kind of naive question related to envers. Can we name a audit table to something other then the default one, i.e., TableName_AUD and ya not just Prefix or suffix, full name.
1 vote
0 answers
148 views

cannot persist audit data with hibernate envers when using UUID as primary key (varchar)

I am using spring boot 2.7.2 and hibername 5.6.9.Final. I use Mariadb and the primary keys are defined as Varchar(255). I store uuid for primary keys and now decided to use hibernate envers which I ...
6 votes
4 answers
7k views

Hibernate Envers - Doesn't write audit records for createQuery(...).executeUpdate(), only .persist() and .merge()

I have 3 ways things get written to the DB public void create(T object) { entityManager.persist(object); } public void update(T object) { object = entityManager.merge(object); } public int ...
0 votes
1 answer
73 views

How to revert the ddl of hibernate envers primary keys to the same behavious as version 5

I'm in the process of upgrading to hibernate 6. We use envers extensively, on some services with complex domains and lots of data. We generate our database migration scripts with liquibase. I was ...
0 votes
0 answers
25 views

Envers : JPA : Audit table does not store revisions of an entity (saving Same entity Multiple times)

I am trying to save an entity which updates(for example: status column gets updated at each stage) multiple times in method. All these revisions are needed to be reflected in its audit table as well. ...
3 votes
1 answer
1k views

Hibernate Envers claims EntityManager is closed

I have a Spring (Boot) application on which I'm trying to use Hibernate Envers. The following bar function throws an IllegalStateException: EntityManager is closed, while the foo function works ...
2 votes
3 answers
4k views

How to query RevisionEntity in hibernate envers

I was trying to log additional user data with the revisions created by Envers. I was able to do that using RevisionEntity and RevisionListener but I'm not able to retrieve the data that is logged. I ...
0 votes
0 answers
59 views

How Hibernate's enver @AuditTable and @CreationTimestamp and different date format for main and public schema cause wrong values in the main schema?

We have an audit schema and Hibernate enver to audit the data: spring: jpa: org: hibernate: envers: default_schema: audit and here are the anoontations. BaseEntity: @Data @...
0 votes
0 answers
43 views

Hibernate envers - Filter results using "IN" condition

I'm using hibernate (5.4.32) envers to audit my tables and I want to retrieve all the results that matching certain criteria with the "IN" condition, example: AuditQuery auditQ = auditReader....
0 votes
1 answer
650 views

Hibernate 6 Envers: How to customize audit table of an @ElementCollection of @CompositeType?

I'm migrating a project from Spring Boot 2.7.x to 3.0.x. One of my entities has a collection with a composite type: @Entity @Audited public class Specialist { @Id @GeneratedValue private ...
0 votes
0 answers
311 views

Hibernate 5 to hibernate 6.2

I m currently migrate from hibernate 5 to 6 I'm using envers with my custom revision table that contain a field RevisionType like this class MyCustomRevision { ... ... RevisionType revisionType; ...
5 votes
4 answers
6k views

How to inject spring beans into the hibernate envers RevisionListener

I am using Spring 5.1 and Hibernate 5.3.9 including hibernate-envers. I don't know how to inject spring beans into the hibernate envers custom RevisionListener. I have tried (@Service or @...
0 votes
1 answer
240 views

Migrating hibernate from 5.6.7 into 6.2.6 . then after updating any data giving "hibernate_sequence' doesn't exist"

I am using MySQL, and I think MySQL does not support sequences. So, how can I resolve this problem? I have tried adding the 'hibernate_sequence' table, but I am still getting an error. The error ...
0 votes
0 answers
65 views

Hibernate envers not setting modified flag when adding element to collection using EmbeddedId

Here is a small illustration of the issue that I am experiencing using hibernate envers 5.6.15. I have a parent entity with two kinds of children: sons and daughters. @Entity @Table(name = "...
0 votes
0 answers
82 views

Envers Query - Don't Join with REVINFO Table

I am running a Hibernate AuditQuery to get revision info for an entity. With the second parameter as false, the result is joined with the REVINFO table: AuditReader reader = AuditReaderFactory.get(em);...
0 votes
0 answers
119 views

How to Audit an @ManyToOne relation with Hibernate envers

When I'm trying to do an audition with my Hibernate envers, my two relations that are @ManyToOne return this error: Method threw 'javax.persistence.EntityNotFoundException' exception. Cannot evaluate ...
3 votes
0 answers
1k views

Error with JSON field using @JdbcTypeCode(SqlTypes.JSON) in Hibernate 6

After upgrading to the latest Spring 3.1.1, the @TypeDef annotation is no longer available. It has been replaced with the @JdbcTypeCode(SqlTypes.JSON) annotation. However, when persisting the entity, ...

1
2 3 4 5
18