java - Envers can't find audit tables -


i want use envers in project. hardest part create audit tables. database structure created flyway migrations. therefore hibernate.hbm2ddl.auto = validate. according documentation should use org.hibernate.envers.tools.hbm2ddl.enversschemagenerator create schema programmatically. didn't find examples how it.

i created flyway migrations audit tables. seems envers can't find them during start dev conf. test conf works fine. here application.yml dev:

spring.datasource: driverclassname: com.mysql.jdbc.driver url: jdbc:mysql://localhost:3306/server?autoreconnect=true&useunicode=true&characterencoding=utf-8&connectioncollation=utf8&charactersetresults=utf-8 username: root spring.jpa: database: mysql show-sql: true hibernate:     ddl-auto: validate     dialect: org.hibernate.dialect.mysql5dialect     naming_strategy: org.hibernate.cfg.improvednamingstrategy properties.org.hibernate.envers:     default_schema: server_audit     audit_table_suffix: _history 

and test:

spring: profiles: test spring.datasource: driverclassname: org.h2.driver url: jdbc:h2:mem:test;mode=mysql;init=create schema if not exists \"public\"\;create schema if not exists \"server_audit\" spring.jpa: database: h2 show-sql: true hibernate:     ddl-auto: validate     dialect: org.hibernate.dialect.h2dialect     naming_strategy: org.hibernate.cfg.improvednamingstrategy 

during start there exception:

java.sql.databasemetadata   : hhh000262: table not found: accounts_history  [lication.main()] ationconfigembeddedwebapplicationcontext : exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.beancreationexception: error creating bean name 'entitymanagerfactory' defined in class path resource  [org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaautoconfiguration.class]: invocation of init method failed; nested exception org.hibernate.hibernateexception: missing table: accounts_history 

then changed hbm2ddl.auto = update output weird:

java.sql.databasemetadata  : hhh000262: table not found: accounts_history org.hibernate.tool.hbm2ddl.schemaupdate  : hhh000388: unsuccessful: create table server_audit.accounts_history org.hibernate.tool.hbm2ddl.schemaupdate  : table 'accounts_history' exists 

and starts.

update can provide example how create audit tables using

org.hibernate.envers.tools.hbm2ddl.enversschemagenerator 

?


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -