0

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

freecks
  • 137
  • 4
  • 18

2 Answers2

2

Please take a look at the Configuration Options:

org.hibernate.envers.default_schema
The default schema name that should be used for audit tables.

org.hibernate.envers.default_catalog
The default catalog name that should be used for audit tables.

The option that you should use depends on if your database.

There is also a bug that if you use the default revision entity mappings provided out of the box by Envers that those mappings won't be properly mapped when using these configuration options, only the tables that are related to the entity mappings.

In order to properly map the REVINFO table to the appropriate schema or catalog, a custom revision entity mapping will need to be used in cojunction with a the @Table annotation in order to explicitly specify the schema/catalog. Please see the section Revision Log that describes using a custom @RevisionEntity annotated entity mapping with Envers.

Naros
  • 19,928
  • 3
  • 41
  • 71
1

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.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348