I have a SpringBoot 3 based Gradle project that uses Hibernate 6 and Liquibase.
The goal is to use the liquibase-hibernate6
dependency to generate an initial Liquibase changelog containing the details of my Java Entity class i.e Item.java
.
The problem is that the generated changelog is basically empty.
What is missing in order to generate Liquibase changelog from my Java Entity class?
val liquibaseVersion: String = "4.23.0"
val liquibaseGradlePluginVersion: String = "2.2.0"
plugins {
java
war
id("org.springframework.boot") version "3.1.1"
id("io.spring.dependency-management") version "1.1.0"
id("org.liquibase.gradle") version "2.2.0"
}
group = "com.example"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.postgresql:postgresql:42.6.0")
implementation("info.picocli:picocli:4.6.3")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.liquibase:liquibase-core:$liquibaseVersion")
implementation("org.liquibase:liquibase-gradle-plugin:$liquibaseGradlePluginVersion")
implementation("org.hibernate.orm:hibernate-core:6.2.5.Final")
implementation("org.liquibase.ext:liquibase-hibernate6:$liquibaseVersion")
implementation("com.fasterxml.jackson.core:jackson-core")
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
liquibaseRuntime("org.postgresql:postgresql:42.6.0")
liquibaseRuntime("info.picocli:picocli:4.6.3")
liquibaseRuntime("org.liquibase:liquibase-core:$liquibaseVersion")
liquibaseRuntime("org.liquibase.ext:liquibase-hibernate6:$liquibaseVersion")
liquibaseRuntime("org.hibernate.orm:hibernate-core:6.2.5.Final")
liquibaseRuntime("org.springframework.boot:spring-boot-starter-data-jpa")
liquibaseRuntime(sourceSets.getByName("main").output)
}
tasks.withType<Test> {
useJUnitPlatform()
}
liquibase {
activities.register("main") {
this.arguments = mapOf(
"changelogFile" to "src/main/resources/config/liquibase/changelog/0.1.0/000000_00000000_initial-changelog.xml",
"url" to "hibernate:spring:com.example?dialect=org.hibernate.dialect.PostgreSQLDialect"
)
}
}
I have a Java Entity:
package com.example.demo;
import jakarta.persistence.*;
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private Long id;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Contents of Liquibase changelog after running generateChangeLog
via Gradle:
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"/>