Hibernate Envers with Spring Boot - configuration

Milan picture Milan · May 5, 2014 · Viewed 22.3k times · Source

I'm trying to setup Hibernate Envers to work with my Spring Boot application.

I've included the Envers dependency and added @Audited annotations and it works fine, but I'm unable to configure specific Envers properties, Spring Boot doesn't seem to pick them up.

Specifically, I've tried to set the different db schema for audit tables by putting these to application.properties, but without luck:

hibernate.envers.default_schema=app_audit

or

org.hibernate.envers.default_schema=app_audit

or

spring.jpa.hibernate.envers.default_schema=app_audit

Neither of these work. Does anyone know how to set these?

EDIT.

As M. Deinum suggested I tried:

spring.jpa.properties.org.hibernate.envers.default_schema=app_audit

and it worked!

Answer

M. Deinum picture M. Deinum · May 5, 2014

For all those configuration settings that aren't by default available you can specify them by simply prefixing them with spring.jpa.properties. Those properties will be added, as is, to the EntityManagerFactory (as JPA Properties).

spring.jpa.properties.org.hibernate.envers.default_schema=app_audit 

Adding the above to the application.properties will add the properties and should configure Hibernate Envers.

This is also documented in the Spring Boot reference guide.

Links

  1. Configure JPA properties
  2. Envers Properties