1

I hope to achieve auditing of my tables using @Audited annotation of the Hibernate Envers project while I'm using Spring Data R2DBC or plain R2DBC to insert data into my tables.

Is this even feasible. I am not able to tell if Spring Data R2DBC uses hibernate at all. I tried adding the @Audited annotation to my entity class to no avail.

this.fnclInfoRepository.save(itfnclinfo).subscribe();
@Data
@Builder
@Audited
public class Itfnclinfo implements Persistable<String> {
  @Id
  private String fnclInfoId;
..
}

I was expecting a new table created by hibernate with the suffix _AUD that holds the copy of all inserted data

Sylvester
  • 421
  • 3
  • 6
  • What database is behind your R2DBC connection? Is it MySQL, Postgres, H2, etc? – Naros May 07 '19 at 13:53
  • The database behind my R2DBC connection is Postgres. Since the original post, I have managed to implement auditing through regular inserts into separate audit tables. – Sylvester May 08 '19 at 14:05
  • 3
    I inquired about database platform because you could use Debezium to perform change-data-capture and transform those inserts into inserts into your audit tables asychronously which decouples that entirely from your application which is a nice separation in the long-run. – Naros May 08 '19 at 15:33

2 Answers2

3

I realize that Spring Data JPA is an abstraction over Hibernate and therefore Spring Data R2DBC is not a JPA provider abstraction and therefore not related to Hibernate. I'll have to come up with another way for auditing.

Sylvester
  • 421
  • 3
  • 6
0

Spring data envers only works with traditional Spring Data JPA.

In a Spring Boot project, you can customize your AuditEvent and AuditEventRepository and setup the change log manually.

Check the Spring Boot docs - Auditing.

It maybe need more extra work, the good part is the auditevent is integrated with Spring Boot Actuator, you can track the auditevents by Actuator urls.

Hantsy
  • 8,006
  • 7
  • 64
  • 109