Bug description
I'm encountering an issue while using Liquibase with Hibernate Envers in my Maven project created with Spring Boot. When running the mvn liquibase:diff command, Liquibase seems to be ignoring the Envers configuration specified in my application.properties. Specifically, the audit tables are being created with default values instead of the configured ones.
Configuration details
application.properties:
spring.datasource.url=jdbc:postgresql://localhost:5432/my_project
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driverClassName=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.naming.implicit-strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
spring.jpa.properties.hibernate.jpa.compliance.query=false
spring.jpa.properties.hibernate.format_sql=false
spring.jpa.properties.hibernate.show_sql=false
spring.jpa.properties.org.hibernate.envers.audit_table_suffix=_aud
spring.jpa.properties.org.hibernate.envers.revision_field_name=id_rev
spring.jpa.properties.org.hibernate.envers.revision_type_field_name=rev_type
spring.jpa.properties.org.hibernate.envers.store_data_at_delete=true
liquibase.properties:
url=jdbc:postgresql://localhost:5432/my_project
username=postgres
password=postgres
driver=org.postgresql.Driver
defaultSchemaName=public
changeLogFile=db/changelog/db.changelog-master.xml
diffChangeLogFile=src/main/resources/db/changelog/db.changelog-diff.xml
referenceUrl=hibernate:spring:br.com.sysagro.model?dialect=org.hibernate.dialect.PostgreSQLDialect
referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceDefaultSchemaName=public
pom.xml (Liquibase Maven Plugin):
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<searchPath>${resource.dir}</searchPath>
<propertyFile>db/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate6</artifactId>
<version>${liquibase.version}</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>${jakarta-validation.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Generated changelog snippet:
<changeSet author="pedro (generated)" id="1704939097953-1">
<createTable tableName="address_AUD">
<column name="id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="REV" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="REVTYPE" type="SMALLINT"/>
</createTable>
</changeSet>
Despite the Envers configuration in application.properties, Liquibase is creating audit tables with default values. For example, as you can see in the generated changelog snippet, the table for the entity address is created with the suffix _AUD instead of the configured _aud, and the revision field is labeled as REV instead of id_rev. This indicates a deviation from the specified Envers settings. I'm uncertain whether this behavior stems from Spring, Hibernate, or Liquibase.
Versions
Java: 21 Spring Boot: 3.2.1 Hibernate Envers: 6.4.1.Final
Comment From: philwebb
This doesn't sound like a bug with Spring Boot itself. I'm not familiar enough with the Liquibase Maven Plugin to be able to offer much advice, but I suspect the plugin isn't aware of configuration defined in application.properties.
This question on stackoverflow.com seems like a similar problem. I would suggest asking for help from the Liquibase community on stackoverflow.com and providing them with a minimal sample project that shows the problem.
If it turns out that there's a bug in Spring Boot, we can reopen this issue.