4

I am trying to generate a diff changelog using Liquibase and Hibernate but when I run the command gradle diffChangeLog I get the following error:

ERROR [liquibase.integration.commandline.Main]: Unexpected error running Liquibase: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'
java.lang.NoSuchMethodError: 'java.lang.Object org.hibernate.id.enhanced.SequenceStyleGenerator.generatorKey()'

I am able to generate a changelog, but only get issues when trying to generate a diff changelog. My build.gradle.kts file is below:

    plugins {
        java
        id("org.springframework.boot") version "2.6.2"
        id("io.spring.dependency-management") version "1.0.11.RELEASE"
        id("org.liquibase.gradle") version "2.1.1"
    }

    group = "com.example"
    version = "0.0.1-SNAPSHOT"
    var sourceCompatibility = "11"
    val postgresVersion = "42.2.19"
    val liquibaseVersion = "2.1.1"
    val lombokVersion = "1.18.20"
    val liquibaseCoreVersion = "3.8.4"
    val liquibaseExtVersion = "5:3.8"
    val hibernateCoreVersion= "5.4.10.Final"

    repositories {
        mavenCentral()
        maven {
            url = uri("https://repo.spring.io/milestone")
        }
        maven {
            url = uri("https://repo.spring.io/snapshot")
        }
    }

    buildscript {
        repositories {
            gradlePluginPortal()
        }
        dependencies {
            classpath("net.ltgt.gradle:gradle-apt-plugin:0.18")
            classpath("org.postgresql:postgresql:42.2.9")
            classpath("org.liquibase.ext:liquibase-hibernate5:3.8")
            classpath("org.liquibase:liquibase-core:3.8.4")
            classpath("org.liquibase:liquibase-gradle-plugin:2.0.2")
            classpath("org.springframework.data:spring-data-jpa:2.2.1.RELEASE")
        }
    }

    dependencies {
        implementation("org.jetbrains:annotations:20.1.0")
        runtimeOnly("org.postgresql:postgresql")

        implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    //  implementation("org.springframework.boot:spring-boot-starter-security")
        implementation("org.springframework.boot:spring-boot-starter-web")
        implementation("org.postgresql:postgresql:$postgresVersion")
        implementation("org.springframework.boot:spring-boot-starter")

        testImplementation("org.springframework.boot:spring-boot-starter-test") {
            exclude(group= "junit", module= "junit")
        }
        //testImplementation("org.springframework.security:spring-security-test")

        testImplementation("org.springframework.boot:spring-boot-starter-test")
        testImplementation("org.hamcrest:hamcrest-library:2.2")


        implementation("org.liquibase:liquibase-core:$liquibaseCoreVersion")
        implementation("org.liquibase.ext:liquibase-hibernate$liquibaseExtVersion")
        implementation("org.springframework.boot:spring-boot:2.6.2")
        implementation("info.picocli:picocli:4.6.1")
        implementation("org.liquibase:liquibase-groovy-dsl:3.0.0")

        liquibaseRuntime("org.liquibase:liquibase-core:$liquibaseCoreVersion")
        liquibaseRuntime("org.liquibase:liquibase-groovy-dsl:2.1.1")
        liquibaseRuntime("org.postgresql:postgresql:$postgresVersion")
        liquibaseRuntime("org.liquibase.ext:liquibase-hibernate$liquibaseExtVersion")
        liquibaseRuntime(sourceSets.getByName("main").compileClasspath)
        liquibaseRuntime(sourceSets.getByName("main").runtimeClasspath)
        liquibaseRuntime(sourceSets.getByName("main").output)

        compileOnly("org.projectlombok:lombok:$lombokVersion")
        annotationProcessor("org.projectlombok:lombok:$lombokVersion")
    }

    tasks.named<Test>("test") {
        useJUnitPlatform()
    }

    tasks {
        // Use the native JUnit support of Gradle.
        "test"(Test::class) {
            useJUnitPlatform()
        }
    }

    liquibase {
        activities.register("main") {
            this.arguments = mapOf(
                    "classpath" to "src/main/resources",
                    "driver" to "org.postgresql.Driver",
                    "logLevel" to "info",
                    "changeLogFile" to "src/main/resources/db/changelog/changes/changelog_002.xml",
                    "url" to "jdbc:postgresql://localhost:54320/postgres?currentSchema=schema",
                    "username" to "postgres",
                    "password" to "postgres",
                    "referenceUrl" to "hibernate:spring:com.example?dialect=org.hibernate.dialect.PostgreSQLDialect" +
                            "&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate." +
                            "SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=" +
                            "org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy")
        }
    }

I have tried to change the versioning around but then get an error saying the driver could not be found.

Any help would be greatly appreciated! Thank you

Antares
  • 518
  • 6
  • 11
user2047296
  • 315
  • 3
  • 12
  • Did you manage to solve this problem? – Vince V. Jan 20 '22 at 14:07
  • 1
    It seems like bug in liquibase. Created an Github issue. https://github.com/liquibase/liquibase/issues/2456 – Jan Cizmar Feb 02 '22 at 15:50
  • seems that they fixed it, but still i am not able to get the fix on the project. were you able to fix it ? – Yamen Nassif Feb 08 '22 at 10:08
  • I also got stuck here after changes in entities using jhipster generator. I tried to change version of hibernate to 6.6.0.Final and also liquibaseVersion to upper one, but with no success – Antares Mar 28 '22 at 13:25

0 Answers0