javaaudithibernate-enversaudit-tablesspring-data-envers

Moving auditing table with java envers to new database instance


I have a Mysql DB, schema name "myschema". This schema has tables, where some of this tables are audit tables. This is my dependency on my java project.

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

Now I had like to remore this audit tables on my currect DB and more them on a separate instance, with a branch new uri.

How can this be done? Any advise, thank you in advance


Solution

  • AFAIK Envers does not support using a separate database/DataSource. There seem to be a couple of ways to get the data to the other database: Oracle Database Link - MySQL Equivalent?

    Alternatively I guess you could write a custom DataSource that delegates statements to different datasources depending on the statement. Check if an auditing table is mentioned and if so send it to the audit database.