Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException - referenceUrl=hibernate:spring (mvn liquibase:diff) #1583

Closed
ghost opened this issue Dec 10, 2020 · 3 comments
Closed

Comments

@ghost
Copy link

ghost commented Dec 10, 2020

Environment

spring-boot-starter-data-jpa project 2.3.0.RELEASE

Liquibase Version:
<liquibase-core.version>4.1.1

Liquibase Integration & Version: <Pick one: CLI, maven, gradle, spring boot, servlet, etc.>
liquibase-maven-plugin

Liquibase Extension(s) & Version:
<liquibase-hibernate5.version>4.1.1

Database Vendor & Version:
mariadb:10.4.11

Operating System Type & Version:
macOS Catalina Version 10.15.7

Description

Hi!

I want to report a bug. I didn’t found a ticket at the moment of writting this lines. If you have a setup which enables you to create a diff-changelog between hibernate and a database a NullPointerException will be thrown.

The reason is that liquibase.database.DatabaseFactory#findCorrectDatabaseImplementation calls isCorrectDatabaseImplementation(connection) on all implementedDatabase's where also liquibase.database.core.CockroachDatabase is contained. Now liquibase.database.core.CockroachDatabase#isCorrectDatabaseImplementation is trying to create a statement but this method returns in our case null because a liquibase.ext.hibernate.database.connection.HibernateConnection has been passed as argument. As a result a NullPointerException will be thrown and can't be catched by a SQLException.

Steps To Reproduce

List the steps to reproduce the behavior.

  • Create java class like:

Entity
@table(name = "person", uniqueConstraints = {
@UniqueConstraint(name = "uc_name", columnNames = "name")
})
public class Person {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(name = "name")
private String name;

}

  • Create a liquibase.properties file like:
    url=jdbc:mariadb://localhost:3310/troubleshoot
    defaultSchemaName=troubleshoot

username=troubleshooter
password=password
driver=org.mariadb.jdbc.Driver

referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUrl=hibernate:spring:at.frink.troubleshoot?
dialect=org.hibernate.dialect.MariaDB53Dialect&
hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&
hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy

  • execute: mvn liquibase:diff

Actual Behavior

NullPointerException

Expected/Desired Behavior

A new changelogfile should be created.

Attached the project for bug reproduction
troubleshoot_.zip

@molivasdat
Copy link
Contributor

Hi @neivkovic We just released 4.2.2 to fix this case. It contains PR #1580 Please update your maven plugin to use 4.2.2 and you should see this error go away. Let us know if it does fix your issue so that we can close this one.

@ghost
Copy link
Author

ghost commented Dec 11, 2020

Thank your for the fast fix. The problem has been resolved!

@ghost
Copy link
Author

ghost commented Dec 11, 2020

I will close the issue. Thank you again!

@ghost ghost closed this as completed Dec 11, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant