GithubHelp home page GithubHelp logo

liquibase / liquibase-hibernate Goto Github PK

View Code? Open in Web Editor NEW
270.0 35.0 154.0 1.27 MB

Liquibase Hibernate Integration

License: Apache License 2.0

Java 99.89% Groovy 0.11%
hacktoberfest core extension oss

liquibase-hibernate's Introduction

Liquibase Hibernate Integration Build and Test Extension

This is a Liquibase extension for connecting to Hibernate. The extension lets you use your Hibernate configuration as a comparison database for diff, diffChangeLog, and generateChangeLog in Liquibase.

Configuring the extension

These instructions will help you get the extension up and running on your local machine for development and testing purposes. This extension has a prerequisite of Liquibase core in order to use it. Liquibase core can be found at https://www.liquibase.org/download.

Compatibility

The Liquibase Hibernate extension requires Liquibase 4.x and Java 1.8+. Use liquibase-hibernate5.jar or liquibase-hibernate6.jar depending on your Hibernate version. Ideally the extension version should be the same one as Liquibase version.

This extension can be used with any method of running Liquibase (Command line, Gradle, Maven, Ant, and others.)

Liquibase CLI

Download the latest released Liquibase extension .jar file and place it in the liquibase/lib install directory. If you want to use another location, specify the extension .jar file in the classpath of your liquibase.properties file.

Maven

This extension is available in the maven repository under group org.liquibase.ext, artifacts:

  • liquibase-hibernate6 Hibernate 6.0+ support
  • liquibase-hibernate5 Hibernate 5.0+ support

Specify the Liquibase extension in the <dependency> section of your POM file by adding the org.liquibase.ext dependency for the Liquibase plugin.

<plugin>
     <!--start with basic information to get Liquibase plugin:
     include <groupId>, <artifactID>, and <version> elements-->
     <groupId>org.liquibase</groupId>
     <artifactId>liquibase-maven-plugin</artifactId>
     <version>4.19.0</version>
     <configuration>
        <!--set values for Liquibase properties and settings
        for example, the location of a properties file to use-->
        <propertyFile>liquibase.properties</propertyFile>
     </configuration>
     <dependencies>
     <!--set up any dependencies for Liquibase to function in your
     environment for example, a database-specific plugin-->
            <dependency>
                 <groupId>org.liquibase.ext</groupId>
                 <artifactId>liquibase-hibernate</artifactId>
                 <version>${liquibase-hibernate.version}</version>
            </dependency>
         </dependencies>
      </plugin>

Contribution

To file a bug, improve documentation, or contribute code, follow our guidelines for contributing.

This step-by-step instructions will help you contribute code for the extension.

Once you have created a PR for this extension you can find the artifact for your build using the following link: https://github.com/liquibase/liquibase-hibernate/actions/workflows/build.yml.

Hibernate 5 vs. Hibernate 6

The master branch is compatible with Hibernate 6+. The hibernate5 branch is compatible with Hibernate 5.6+

Ideally changes should go into the hibernate5 branch and then be merged into master in order to support Hibernate 5 and 6.

Documentation

Using Liquibase with Hibernate

More Information

For more information, see the project wiki.

Issue Tracking

Any issues can be logged in the Github issue tracker.

License

This project is licensed under the Apache License Version 2.0.

Using Liquibase Test Harness' Diff test

Liquibase's Hibernate extension uses Liquibase Test Harness for integration testing.

The HibernateDiffCommandTest class extends the DiffCommandTest class from Test Harness and utilizes the ability to check differences between two databases. As Hibernate is not a Relational database, this is our method of checking that database objects generated/updated by the Liquibase Hibernate extension against a database have the correct attributes.

In general the DiffCommandTest works by utilizing the Liquibase diff command to check differences between two databases, then it creates a changelog file based on diff, then it applies these changes to the target database and checks the diff again. There still could be some differences afterwards as different DBs support different features, so while checking diffs again the test will ignore diffs that are expected.

Configurations for this test are hosted in 2 files:

  • src/test/resources/harness-config.yml -- this is a general config file for Test Harness where DB connection details are specified.
  • src/test/resources/liquibase/harness/diff/diffDatabases.yml -- this file specifies which DBs should be compared and what the diffs are expected even after we try to bring the target DB to same state as the reference DB.

The DiffCommandTest will take all pairs of targetDB-referenceDB from diffDatabases.yml . The test also takes the *.cfg.xml configuration files into consideration. And then the paths to these config files work as the DB connection URLs in the harness-config.yml file.

liquibase-hibernate's People

Contributors

alekseiitc avatar dependabot-preview[bot] avatar dependabot[bot] avatar filipelautert avatar fleboulch avatar fxbonnet avatar github-actions[bot] avatar haster avatar henri-tremblay avatar jandroav avatar jnewton03 avatar jonenst avatar jrdalpra avatar kristyldatical avatar kushnirykoleh avatar leovr avatar liquibot avatar mcred avatar molivasdat avatar msvticket avatar nmck257 avatar nvoxland avatar r2-lf avatar rlamarche avatar smty2018 avatar timothy-volvo avatar vetler avatar vivekboii avatar yong-jie-gong avatar yuri1969 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liquibase-hibernate's Issues

NUMBER is missing precision and scale

HBM2DDL uses the sql tpye NUMERIC(18,0) for the Java type long

But the generated diff changelog uses the type NUMBER without any precision or scale as the column type

I am using the FirebirdDialect.

NPE when running diffChangeLog

Im experiencing a nullpointer exception when running diffChangeLog.

Command & Output :

liquibase --changeLogFile=changelog.xml --url=jdbc:mysql://localhost/accounting?characterEncoding=utf8 --referenceUrl=referenceUrl=hibernate:spring:src/main/resources/appContext-accountingService.xml?bean=accountingSessionFactory?dialect=org.hibernate.dialect.MySQL5Dialect --username=flexifin --password=flexifin --referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver diffChangeLog
Liquibase diffChangeLog Failed: java.lang.NullPointerException

Class path :

ls
README.txt          hibernate-core-4.2.8.Final.jar  mysql-connector-java-5.1.27.jar spring-beans-3.2.5.RELEASE.jar
h2-1.3.175.jar          liquibase-hibernate4-3.2.jar    snakeyaml-1.13.jar      spring-core-3.2.5.RELEASE.jar

Happy to provide any further information if required.

Max unique constraint length ignored

Hello,

In UniqueConstraintSnapshotGenerator (at or around line 60) the name for the unique constraint is determined without checking the max length for constraints for the dialect. I'm running into an issue with this for mysql which has a relatively low max length for contraint names (64 characters, I believe)

String name = "UC_" + table.getName().toUpperCase() + column.getName().toUpperCase() + "_COL";

diffChangeLog fails with null exception

Unexpected error running Liquibase: java.lang.NullPointerException

[ERROR] liquibase - java.lang.NullPointerException
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:123) ~[liquibase-core-3.3.2.jar:na]
at liquibase.integration.commandline.Main.doMigration(Main.java:936) [liquibase-core-3.3.2.jar:na]
at liquibase.integration.commandline.Main.run(Main.java:175) [liquibase-core-3.3.2.jar:na]
at liquibase.integration.commandline.Main.main(Main.java:94) [liquibase-core-3.3.2.jar:na]

For more information, use the --logLevel flagCaused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13) ~[liquibase-core-3.3.2.jar:na]
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121) ~[liquibase-core-3.3.2.jar:na]
... 3 common frames omitted
Caused by: java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(Matcher.java:1283) ~[na:1.8.0_31]
at java.util.regex.Matcher.reset(Matcher.java:309) ~[na:1.8.0_31]
at java.util.regex.Matcher.(Matcher.java:229) ~[na:1.8.0_31]
at java.util.regex.Pattern.matcher(Pattern.java:1093) ~[na:1.8.0_31]
at liquibase.diff.output.StandardObjectChangeFilter$Filter.matches(StandardObjectChangeFilter.java:104) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.StandardObjectChangeFilter.include(StandardObjectChangeFilter.java:70) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.StandardObjectChangeFilter.includeMissing(StandardObjectChangeFilter.java:51) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:28) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:99) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:145) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:125) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:76) ~[liquibase-core-3.3.2.jar:na]
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:64) ~[liquibase-core-3.3.2.jar:na]
at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:61) ~[liquibase-core-3.3.2.jar:na]
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8) ~[liquibase-core-3.3.2.jar:na]
... 4 common frames omitted

:liquibaseDiffChangelog FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':liquibaseDiffChangelog'.

    Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home/bin/java'' finished with non-zero exit value 255

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Environment : Mac OSX 10.10
DB Postgres 9.3.5.2
Java 8

More detail needed in WIKI on how to use this

Hello,

More detail is needed in the wiki to answer some basic usage questions:

  1. Is it compatible with liquibase-maven-plugin? (version 3.0.7, which seems to be the newest, has a 'diff' command, but not a 'diffChangeLog' command'. The former seems to ignore a 'referenceUrl' of 'hibernate:ejb:XXX' (where XXX is my JPA persistence unit name)
  2. Assuming I run liquibase from the command line (like in your wiki example:
    liquibase --changeLogFile=changelog.xml --url=jdbc:yourdatabase --referenceUrl=hibernate:ejb3:myPersistenceUnit diffChangeLog) what considerations should I take regarding the classpath? I assume I need to tell liquibase where my classes / jars are. How do recommend approaching that?

hibernate.ejb.naming_strategy ignored with latest release

Hello,

The naming strategy defined in my persistence.xml using the 'hibernate.ejb.naming_strategy' property is no longer being used to affect the names of tables in the change log generated by the diffChangeLog operation. I'm using the ejb3 approach with a reference url: hibernate:ejb3:XXX. Any suggestions?

This worked with past versions, but seems to no longer work with version 3.4 (from maven).

I'm using the latest hibernate: 4.3.5.

-Matt

Composite ID support

From http://forum.liquibase.org/topic/liquibase-hibernate-and-composite-id#49382000000939002

I'm trying to get a composite-id to work with liquibase but I can't get it done.

<hibernate-mapping package="com.my.domain">
  <class dynamic-insert="true" dynamic-update="true" name="ExamFormAttribute" table="exam_form_attribute">
    <!-- Database identity -->
    <composite-id>
        <!--<key-property name="form" />-->
      <key-many-to-one name="form" column="form" class="com.my.domain.ExamForm" />
      <key-many-to-one name="attribute" column="attribute" class="com.my.domain.ExamAttribute" />
    </composite-id>

    <property name="attOrder" type="integer"/>
  </class>
</hibernate-mapping>

I get the following error:

org.hibernate.MappingException: entity class not found: com.my.domain.ExamFormAttribute
 at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:137) 

To explain a bit more, I am trying to generate my changelog from my hibernate files. If I put a simple id field it works great but as soon as I do a composite-id, it fails. I have a relation A-----[order]------B so I need to map a table with A_id, B_id + my parameter [order]. Liquibase-hibernate can't seem to be able to generate a changelog from that.

diffChangeLog Failed: Unknown Reason

Generating a diffChangelog fails with : "Unknown Reason"

Command :

liquibase --changeLogFile=changelog.xml --url=jdbc:mysql://localhost/accounting?characterEncoding=utf8 --referenceUrl=referenceUrl=hibernate:spring:src/main/resources/appContext-accountingService.xml?bean=accountingSessionFactory?dialect=org.hibernate.dialect.MySQL5Dialect --username=flexifin --password=flexifin --referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver diffChangeLog
Liquibase diffChangeLog Failed: Unknown Reason

Path :

ls
README.txt          h2-1.3.175.jar          hibernate-core-4.2.8.Final.jar  liquibase-hibernate4.2-3.3.jar  mysql-connector-java-5.1.27.jar snakeyaml-1.13.jar      spring-beans-3.2.5.RELEASE.jar  spring-core-3.2.5.RELEASE.jar

Happy to provide further information if required.

Extension fails to load hibernate driver and breaks if I manually specify it

I'm using liquibase 3.3.2, Hibernate 4.3.0.Final, java 1.7.0_71 and the liquibase-hibernate4-3.5.jar. My CLASSPATH environmental variable is empty, but some stuff gets added to it by the liquibase shell script. When I'm using normal liquibase commands interacting, and I remove the extension from $LIQUIBASE_HOME/lib/ directory without the extension it works just fine. UPDATE: I reran the commands with DEBUG output on to provide some more information.

$ echo $CLASSPATH


$ java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

$ liquibase --version
Liquibase Version: 3.3.2

$ liquibase diffChangeLog
//The below is the stuff liquibase is adding to my classpath
.:/c/repos/ServeDirtyLibsInJava/liquibaseLib/liquibase.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/liquibase-hibernate4-3.5.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/snakeyaml-1.13.jar
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:42 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateClassicDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
DEBUG 1/19/15 10:20 AM: liquibase: Connected to root@localhost@jdbc:mysql://localhost:3306/dirtylibs
DEBUG 1/19/15 10:20 AM: liquibase: Setting auto commit to false from true
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect)

SEVERE 1/19/15 10:20 AM: liquibase: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect)
liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialec
t.MySQL5Dialect)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:69)
        at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1169)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:239)
        at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
        at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:50)
        ... 4 more
Caused by: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect)
        at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:191)
        ... 6 more

My liquibase.properties file

driver=com.mysql.jdbc.Driver
classpath=mysql-connector-java-5.1.6.jar
url=jdbc:mysql://localhost:3306/dirtylibs
username=root
password=password
changeLogFile=changelog.xml
#referenceDriver=liquibase.ext.hibernate.database.connection.HibernateDriver
referenceUrl=hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect
referenceUsername=root
referencePassword=password

If I uncomment my referenceDriver I get this. Is there something I'm missing here? I thought I had all the required dependencies, and I'm not sure if this is some manifestation of the earlier problem where the extension could not load stuff properly.

$ liquibase diffChangeLog
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateEjb3Database as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateClassicDatabase as a Liquibase service because org.hibernate.dialect.Dialect is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.snapshot.SequenceSnapshotGenerator as a Liquibase service because org.hibernate.id.factory.IdentifierGeneratorFactory is not in the classpath
WARNING 1/19/15 12:49 AM: liquibase: Can not use class liquibase.ext.hibernate.snapshot.TableSnapshotGenerator as a Liquibase service because org.hibernate.id.factory.IdentifierGeneratorFactory is not in the classpath
Unexpected error running Liquibase: org.hibernate.sql.Alias
SEVERE 1/19/15 10:22 AM: liquibase: org.hibernate.sql.Alias
java.lang.NoClassDefFoundError: org/hibernate/sql/Alias
        at liquibase.ext.hibernate.snapshot.PrimaryKeySnapshotGenerator.<clinit>(PrimaryKeySnapshotGenerator.java:27)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at liquibase.snapshot.SnapshotGeneratorFactory.<init>(SnapshotGeneratorFactory.java:29)
        at liquibase.snapshot.SnapshotGeneratorFactory.getInstance(SnapshotGeneratorFactory.java:43)
        at liquibase.snapshot.SnapshotControl.addType(SnapshotControl.java:95)
        at liquibase.snapshot.SnapshotControl.setTypes(SnapshotControl.java:88)
        at liquibase.snapshot.SnapshotControl.<init>(SnapshotControl.java:25)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:185)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: java.lang.ClassNotFoundException: org.hibernate.sql.Alias
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 18 more

After adding the hibernate jar to the liquibase/lib folder (which is really wrong) the error turned into this. I'm going to try to revert to an older version of liquibase.

$ liquibase --logLevel=DEBUG diffChangeLog
.:/c/repos/ServeDirtyLibsInJava/liquibaseLib/liquibase.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/hibernate-core-4.3.0.Final.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/liquibase-hibernate4-3.5.jar:/c/repos/ServeDirtyLibsInJava/liquibaseLib/lib/snakeyaml-1.13.jar
WARNING 1/19/15 10:38 AM: liquibase: Can not use class liquibase.ext.hibernate.database.HibernateSpringDatabase as a Liquibase service because org.springframework.beans.factory.support.BeanDefinitionRegistry is not in the classpath
DEBUG 1/19/15 10:38 AM: liquibase: Connected to root@localhost@jdbc:mysql://localhost:3306/dirtylibs
DEBUG 1/19/15 10:38 AM: liquibase: Setting auto commit to false from true
WARNING 1/19/15 10:38 AM: liquibase: Unknown database: Hibernate
DEBUG 1/19/15 10:38 AM: liquibase: Connected to null@hibernate:spring:com.companyname.dirtylibs.persistence.entities?dialect=org.hibernate.dialect.MySQL5Dialect
DEBUG 1/19/15 10:38 AM: liquibase: Not adjusting the auto commit mode; it is already false
INFO 1/19/15 10:38 AM: liquibase: Error getting default schema
java.lang.NullPointerException
        at liquibase.executor.jvm.JdbcExecutor$QueryCallableStatementCallback.doInCallableStatement(JdbcExecutor.java:383)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:96)
        at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:132)
        at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:143)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:166)
        at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:161)
        at liquibase.database.AbstractJdbcDatabase.getConnectionSchemaName(AbstractJdbcDatabase.java:318)
        at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:301)
        at liquibase.CatalogAndSchema.customize(CatalogAndSchema.java:132)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:116)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
DEBUG 1/19/15 10:38 AM: liquibase: Computed checksum for 1421681927678 as b60efdd1567f2fd4e5407a8d157cb0b6
Unexpected error running Liquibase: java.lang.NullPointerException

SEVERE 1/19/15 10:38 AM: liquibase: java.lang.NullPointerException
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:123)
        at liquibase.integration.commandline.Main.doMigration(Main.java:936)
        at liquibase.integration.commandline.Main.run(Main.java:175)
        at liquibase.integration.commandline.Main.main(Main.java:94)
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
        ... 3 more
Caused by: java.lang.NullPointerException
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.getDatabaseCatalogNames(CatalogSnapshotGenerator.java:82)
        at liquibase.snapshot.jvm.CatalogSnapshotGenerator.snapshotObject(CatalogSnapshotGenerator.java:41)
        at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
        at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
        at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163)
        at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:55)
        at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37)
        at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126)
        at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119)
        at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
        at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 4 more

Error running Liquibase-Hibernate with Spring Data JPA (and no persistence.xml file)

I'm trying to make Liquibase-Hibernate work with JHipster, see issue #754

Here is my configuration:

        <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <changeLogFile>classpath:config/liquibase/master.xml</changeLogFile>
                    <url>hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect</url>
                    <referenceDriver>com.mysql.jdbc.Driver</referenceDriver>
                    <referenceUrl>jdbc:mysql://localhost:3306/jhipster</referenceUrl>
                    <referenceDefaultSchemaName>jhipster</referenceDefaultSchemaName>
                    <referenceUsername>root</referenceUsername>
                    <referencePassword></referencePassword>
                    <verbose>true</verbose>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4.2</artifactId>
                        <version>3.4</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>${spring-boot.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

When running "mvn liquibase:diff -X", I get:

[INFO] ------------------------------------------------------------------------
[INFO] Settings
----------------------------
[INFO]     driver: null
[INFO]     url: hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect
[INFO]     username: null
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: null
[INFO]     properties file will override? false
[INFO]     prompt on non-local database? true
[INFO]     clear checksums? false
[INFO]     changeLogFile: classpath:config/liquibase/master.xml
[INFO]     context(s): null
[INFO]     label(s): null
[INFO]     referenceDriver: com.mysql.jdbc.Driver
[INFO]     referenceUrl: jdbc:mysql://localhost:3306/jhipster
[INFO]     referenceUsername: root
[INFO]     referencePassword: null
[INFO]     referenceDefaultSchema: jhipster
[INFO]     diffChangeLogFile: null
[INFO] ------------------------------------------------------------------------
INFO 18/11/14 16:26: liquibase-hibernate: Reading hibernate configuration hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQLInnoDBDialect
INFO 18/11/14 16:26: liquibase-hibernate: Found package com.mycompany.myapp.domain
INFO 18/11/14 16:26: liquibase-hibernate: Found dialect org.hibernate.dialect.MySQLInnoDBDialect
[DEBUG] Resolved location pattern [classpath*:com/mycompany/myapp/domain/**/*.class] to resources []
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.590 s
[INFO] Finished at: 2014-11-18T16:26:56+01:00
[INFO] Final Memory: 20M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.0:diff (default-cli) on project jhipster: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL: class path resource [] cannot be resolved to URL because it does not exist -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.0:diff (default-cli) on project jhipster: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: liquibase.exception.DatabaseException: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:54)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:321)
    ... 22 more
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:591)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443)
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfigurationFromScanning(HibernateSpringDatabase.java:226)
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfiguration(HibernateSpringDatabase.java:54)
    at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:45)
    at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:123)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:143)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:45)
    ... 23 more
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
    at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187)
    at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:588)
    ... 30 more

I think this is because I don't have a persistence.xml file with Spring Data JPA.

custom dialect class not found

It would be great to include project classpath to be able to use custom dialect. The workaround is to include as dependency the project jar generated, but it's a bit odd to do like that and after each code change we should generate a package.

liquibase:migrate will empty exists data in table

i use jhipster to generate my application. jhipster will automatically generate some entities, like User, and pre-populate some test data. i add an entity named Company to my app. and add @ManyToOne relation to User like this

    @JsonIgnore
    @ManyToOne
    @JoinColumn(name = "company_id", nullable = true)
    private Company company;

and in the Company.java, i add these lines:

  @JsonIgnore
    @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "company")
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<User> users = new HashSet<>();

these are just ordinary ManyToOne OneToMany relations.
then i run

liquibase:diff

there was a file named 20150519174124_changelog.xml created in changelog folder. the content is:

<?xml version="1.0" encoding="UTF-8"?>
<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-3.3.xsd">
   <changeSet author="WB (generated)" id="1432028497937-1">
      <addColumn tableName="JHI_USER">
         <column name="company_id" type="bigint"/>
      </addColumn>
   </changeSet>
   <changeSet author="WB (generated)" id="1432028497937-2">
      <addForeignKeyConstraint baseColumnNames="company_id"
                               baseTableName="JHI_USER"
                               constraintName="FK_a6rnbplt9wu0xh04m15ds0v3d"
                               deferrable="false"
                               initiallyDeferred="false"
                               referencedColumnNames="id"
                               referencedTableName="COMPANY"/>
   </changeSet>
   <changeSet author="WB (generated)" id="1432028497937-3">
      <dropNotNullConstraint columnDataType="boolean"
                             columnName="activated"
                             tableName="JHI_USER"/>
   </changeSet>
</databaseChangeLog>

and i open a terminal window , cd to my application folder, run these command:

mvn spring-boot:run

and the application started fine except my User table was totally cleared. i have these problem a few days now, and i really dont know how to make my code work. i try to re-generate jhipster app, and do some steps like i listed. it always make my user table cleared. so i guess this would be a liqubase problem and i need some help.

┆Issue is synchronized with this Jira Bug by Unito

Diff is repeating changeSets

Due to liquibase-core bug CORE-1987, I am using liquibase maven plugin 3.0.6 and liquibase-hibernate 3.0, because is the only combination that makes liquibase:diff work.

But I realized that even when hibernate mappings and database are synced, liquibase:diff is producing always the same changesets, as if data base was empty.

¿Is this a bug of the older versions I am using? I can't check it out against liquibase maven 3.2.2 and liquibase-hibernate 3.4, because it always produces void changesets.

MSSQL sequence support

Sequence support still doesn't work for inserting data.
Please add line of code bellow to MSSQLDatabase constructor

    super.sequenceNextValueFunction = "next value for %s";

It belongs to core not to hibernate

Hibernate4 connection Metadata

Hi all!
I'm just starting a project with Maven+Spring+HIbernate+JPA+liquibase and want for a complete integration.

In my pom I'm using liquibase-maven-plugin 3.1.0, liquibase-hibernate4 3.2 and the latest core.

I've found when I run a liquibase:dif I got a NullPointerException at line 30 in liquibase.database.jvm.JdbcConnection.

I this place when attach the Database, add the SQLKeybwords to the ReservedWords obtained from the HibernateConnectionMetadata.. but the getSQLKeywords always will return null, it's hardcoded, so always will fail... isn't it?

The specific line is
database.addReservedWords(Arrays.asList(this.getWrappedConnection().getMetaData().getSQLKeywords().toUpperCase().split(",\s*")));

So.. I asked. there any work-arround, or planned to change this for new releases?
Thanks in advance!!

Error when I execute mvn liquibase:diff

Hi All,

I'm working for a personal project with jHipster. In order to update liquibase changeset I'm using the mvn command liquibase:diff.

But an error appears.

Here my config :
Apache Maven 3.2.3 (33f8c3e1027c3ddde99d3cdebad2656a31e8fdf4; 2014-08-11T22:58:10+02:00)
Maven home: /Users/tripless/Applications/apache-maven-3.2.3
Java version: 1.8.0_40, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.2", arch: "x86_64", family: "mac"

Here my liquibase config :
[DEBUG] Configuring mojo 'org.liquibase:liquibase-maven-plugin:3.3.2:diff' with basic configurator -->
DEBUG changeLogFile = src/main/resources/config/liquibase/master.xml
DEBUG clearCheckSums = false
DEBUG diffChangeLogFile = src/main/resources/config/liquibase/changelog/20150407191323_changelog.xml
DEBUG diffExcludeObjects = oauth_access_token, oauth_approvals, oauth_client_details, oauth_client_token, oauth_code, oauth_refresh_token
DEBUG driver = org.postgresql.Driver
DEBUG emptyPassword = false
DEBUG includeArtifact = true
DEBUG includeTestOutputDirectory = true
DEBUG logging = debug
DEBUG password = mypassword
DEBUG project = MavenProject: net.tripless.passenger.server:passenger:0.0.1-SNAPSHOT @ /Users/tripless/AndroidStudioProjects/Passenger/jhipster/pom.xml
DEBUG promptOnNonLocalDatabase = true
DEBUG propertyFileWillOverride = false
DEBUG referenceUrl = hibernate:spring:net.tripless.passenger.server.domain?dialect=org.hibernate.dialect.PostgreSQL82Dialect
DEBUG url = jdbc:postgresql://localhost:5432/passenger
DEBUG username = postgres
DEBUG verbose = true

Here the error generated by maven :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.089 s
[INFO] Finished at: 2015-04-07T21:13:26+02:00
[INFO] Final Memory: 26M/279M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:diff (default-cli) on project passenger: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.2:diff (default-cli) on project passenger: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:145)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:123)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:100)
at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:176)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:369)
... 22 more
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
... 25 more
Caused by: java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at liquibase.diff.output.StandardObjectChangeFilter$Filter.matches(StandardObjectChangeFilter.java:104)
at liquibase.diff.output.StandardObjectChangeFilter.include(StandardObjectChangeFilter.java:70)
at liquibase.diff.output.StandardObjectChangeFilter.includeMissing(StandardObjectChangeFilter.java:51)
at liquibase.diff.output.changelog.ChangeGeneratorChain.fixMissing(ChangeGeneratorChain.java:28)
at liquibase.diff.output.changelog.ChangeGeneratorFactory.fixMissing(ChangeGeneratorFactory.java:99)
at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:145)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:125)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:76)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:64)
at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:61)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
... 26 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Do you have any idea about this error ?
I can copy the entire trace if needed.

Thanks a lot.

Alexis

Running this via maven plugin

I can't figure out how to get this to run from the maven plugin.. I keep getting:
Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:ejb3:myPersistenceUnit)

Please let me know how I'm supposed to get this to go from maven.. the instructions are a bit sparse. Do I need to implement an interface?

-Matt

stack trace below:


[INFO] Settings
----------------------------
[INFO]     driver: org.h2.Driver
[INFO]     url: jdbc:h2:mem:adb;DB_CLOSE_DELAY=-1
[INFO]     username: sa
[INFO]     password: *****
[INFO]     use empty password: false
[INFO]     properties file: src/main/resources/liquibase.properties
[INFO]     properties file will override? false
[INFO]     prompt on non-local database? false
[INFO]     clear checksums? false
[INFO]     changeLogFile: src/main/resources/db.changelog-master.xml
[INFO]     context(s): dev
[INFO]     referenceDriver: null
[INFO]     referenceUrl: hibernate:ejb3:myPersistenceUnit
[INFO]     referenceUsername: null
[INFO]     referencePassword: null
[INFO]     referenceDefaultSchema: null
[INFO]     diffChangeLogFile: null
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:h2:mem:adb;DB_CLOSE_DELAY=-1
[INFO] Loading artfacts into URLClassLoader
[INFO]   artifact: file:/Users/matt/.m2/repository/org/liquibase/liquibase-core/3.2.0/liquibase-core-3.2.0.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/apache/velocity/velocity/1.7/velocity-1.7.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-servlet/8.1.14.v20131031/jetty-servlet-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-security/8.1.14.v20131031/jetty-security-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-server/8.1.14.v20131031/jetty-server-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/3.0.0.v201112011016/javax.servlet-3.0.0.v201112011016.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-continuation/8.1.14.v20131031/jetty-continuation-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-http/8.1.14.v20131031/jetty-http-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-io/8.1.14.v20131031/jetty-io-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/eclipse/jetty/jetty-util/8.1.14.v20131031/jetty-util-8.1.14.v20131031.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/junit/junit/4.11/junit-4.11.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/liquibase/ext/liquibase-hibernate4/3.4/liquibase-hibernate4-3.4.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/hibernate-core/4.3.5.Final/hibernate-core-4.3.5.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.4.Final/hibernate-commons-annotations-4.0.4.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.5.Final/hibernate-entitymanager-4.3.5.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/org/hibernate/hibernate-envers/4.3.1.Final/hibernate-envers-4.3.1.Final.jar
[INFO]   artifact: file:/Users/matt/.m2/repository/com/h2database/h2/1.4.178/h2-1.4.178.jar
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.374s
[INFO] Finished at: Thu Jun 19 16:13:06 CDT 2014
[INFO] Final Memory: 7M/18M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.0:diff (default-cli) on project database: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (hibernate:ejb3:myPersistenceUnit) -> [Help 1]
[ERROR] 

Sequence generators are missing

I am using the following annotations in combination with my @Id annotation:

    @GeneratedValue(
                strategy = GenerationType.SEQUENCE,
            generator = "name_seq_generator")
    @SequenceGenerator(
            name = "name_seq_generator",
            sequenceName = "name_seq")

which should create a sequence generator with name "name_seq".
These statements are not created with the liquibase-hibernate extension

Liquibase liquibase-maven-plugin creates tables but tables cannot be found in Integration Tests: org.hibernate.HibernateException

Hi

I am using Liquibase. I want the database tables to be created before the Integration Tests.

The code is located on GitHib: https://github.com/rajivj2/example2/

The EmployeeJpaDAOIT.java is the class that contains the test. All I want to do is have the tables created before the test actually starts. I can see the plugin creates the tables at runtime but the Integration Tests throws the following Exception:

Caused by: org.hibernate.HibernateException: Missing table: employee

I have tried various things but the table cannot be found. Could you please look into what the issue is?

Hibernate4: Envers tables not generated

It seems Envers was handled in previous version but has been removed with Hibernate4.

Could it be possibe to have the Envers tables generated as well ?

Thanks

NPE when building diff -> Catalog.toString() is null

Stack:

Caused by: java.lang.NullPointerException
at liquibase.structure.DatabaseObjectComparator.compare(DatabaseObjectComparator.java:16)
at liquibase.structure.DatabaseObjectComparator.compare(DatabaseObjectComparator.java:7)
at java.util.TreeMap.compare(TreeMap.java:1188)
at java.util.TreeMap.put(TreeMap.java:531)
at java.util.TreeSet.add(TreeSet.java:255)
at java.util.AbstractCollection.addAll(AbstractCollection.java:334)
at java.util.TreeSet.addAll(TreeSet.java:312)
at liquibase.diff.DiffResult.getMissingObjects(DiffResult.java:77)
at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:136)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:121)
at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:54)
at liquibase.integration.ant.DiffDatabaseToChangeLogTask.outputDiff(DiffDatabaseToChangeLogTask.java:15)
at liquibase.integration.ant.DiffDatabaseTask.executeWithLiquibaseClassloader(DiffDatabaseTask.java:159)
... 32 more

The incriminated object is a Catalog, which the toString() method is returning null.

Liquibase version: 3.0.6
Liquibase-Hibernate4: 3.2

Thanks !

error in TableSnapshotGenerator

Hi

I'm using liquibase-hibernate3 version 3.3
I encountered this problem.

In class liquibase.ext.hibernate.snapshot.TableSnapshotGenerator. On line 82
primaryKey.setName(table.getPrimaryKey().getName());
, the "table.getPrimaryKey()" statement returns null, ans thus it throws an NPE and the liquibase operation fails.

When replacing this line with
primaryKey.setName(column.getName());
It work better (but not sure at all of potential negative impacts)

Thank's for your job!

NullPointerException when using liquibase-hibernate with Liquibase Maven Plugin

Hi,

Unfortunately it looks like liquibase-hibernate4 version 3.4 does not work with Liquibase Maven Plugin. I created a very simple project to reproduce the issue: https://github.com/mdettlaff-mb/LiquibaseHibernateTest

When I run:

$ mvn -e liquibase:diff

I get this error:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.0:diff (default-cli) on project liquibase-hibernate-test: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.0:diff (default-cli) on project liquibase-hibernate-test: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:371)
        at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:129)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
        ... 19 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:74)
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:58)
        at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:159)
        at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:367)
        ... 22 more
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
        at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:72)
        ... 25 more
Caused by: java.lang.NullPointerException
        at liquibase.diff.core.StandardDiffGenerator.compareObjectType(StandardDiffGenerator.java:73)
        at liquibase.diff.core.StandardDiffGenerator.compare(StandardDiffGenerator.java:49)
        at liquibase.diff.DiffGeneratorFactory.compare(DiffGeneratorFactory.java:100)
        at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:143)
        at liquibase.command.DiffCommand.run(DiffCommand.java:132)
        at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
        ... 26 more

When I change the Liquibase Maven Plugin version from 3.2.0 to 3.1.1 I get a different error, but it seems that this version is no longer supported, so it's probably normal.

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (default-cli) on project liquibase-hibernate-test: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:3.1.1:diff failed: An API incompatibility was encountered while executing org.liquibase:liquibase-maven-plugin:3.1.1:diff: java.lang.NoSuchMethodError: liquibase.structure.core.Schema.setDefault(Ljava/lang/Boolean;)Lliquibase/structure/core/Schema;

Running with Liquibase 3.2.0 from the command line instead of Maven plugin works as expected.

$ liquibase --url "jdbc:h2:~/tmp/sampledb;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE" --username sa --password sa --referenceUrl="hibernate:ejb3:samplepu?hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy" --changeLogFile="src/main/resources/db-changelog.xml" --classpath="target/classes" diffChangeLog

ConcurrentModificationException when running liquibase:diff

I get a java.util.ConcurrentModificationException when running the diff command against a PostgreSQL database.

The command was working and the error only appeared after some time (probably after adding some specific mapping). I am running version 3.6-SNAPSHOT. Any ideas/pointers?

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.1:diff (default-cli) on project xxx: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.util.ConcurrentModificationException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.1:diff (default-cli) on project xxx: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.util.ConcurrentModificationException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.util.ConcurrentModificationException
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 25 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.util.ConcurrentModificationException
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:123)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:100)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:149)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:369)
    ... 28 more
Caused by: liquibase.command.CommandExecutionException: java.util.ConcurrentModificationException
    at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
    ... 31 more
Caused by: java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
    at java.util.ArrayList$Itr.next(ArrayList.java:851)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:235)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:221)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:241)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:241)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:241)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:263)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:60)
    at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37)
    at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119)
    at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
    at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
    at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
    at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
    ... 32 more
[ERROR] 
[ERROR] 

diffChangeLog generates autoIncrement="true" that doesn't make sense

Hello,

an attempt to generate Changelog from a JPA annotated entity below...

@Entity
@Table(schema="system", name="db_version")
public class DBVersionEntity implements Serializable {
    private String version;
    private Date timestamp;
    
    @Id
    @Column(name="version", length=32, nullable=false)
    public String getVersion() {
        return version;
    }
    
    public void setVersion(String version) {
        this.version = version;
    }
    
    @Column(name="timestamp")
    public Date getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }
}

... results in Changelog containing autoIncrement="true" clause on a VARCHAR column. In this case it is a primary key column, which may or may not matter. Sample below.

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd" >
    <changeSet author="qdms (generated)" id="1389133852345-1">
        <createTable schemaName="system" tableName="db_version">
            <column autoIncrement="true" name="version" type="VARCHAR(32)">
                <constraints primaryKey="true" primaryKeyName="db_versionPK"/>
            </column>
            <column name="timestamp" type="timestamp"/>
        </createTable>
    </changeSet>
</databaseChangeLog>

Such Changeset makes the subsequent update/migrate action to fail as shown below.

Liquibase update Failed: Unknown property autoIncrement for liquibase.datatype.core.VarcharType varchar(32)
SEVERE 8.1.14 17:20:liquibase: changeset.xml::x::x: Unknown property autoIncrement for liquibase.datat
ype.core.VarcharType varchar(32)
java.lang.RuntimeException: Unknown property autoIncrement for liquibase.datatype.core.VarcharType varchar(32)
        at liquibase.datatype.DataTypeFactory.fromDescription(DataTypeFactory.java:167)
        at liquibase.change.core.CreateTableChange.generateStatements(CreateTableChange.java:65)
        at liquibase.change.AbstractChange.generateStatementsVolatile(AbstractChange.java:245)
        at liquibase.change.AbstractChange.warn(AbstractChange.java:305)
        at liquibase.changelog.visitor.ValidatingVisitor.visit(ValidatingVisitor.java:89)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:64)
        at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:147)
        at liquibase.Liquibase.update(Liquibase.java:134)
        at liquibase.integration.commandline.Main.doMigration(Main.java:864)
        at liquibase.integration.commandline.Main.main(Main.java:133)

UPDATE: same trouble was apparently reported in issue 30 a month ago. No comment on that so far? Am I understanding it right that no-one is effectively using or maintaining this project anymore? Not particularly encouraging...

drop All Database Objects fail

when i am trying to drop all objects from a database using Liquibase, its getting error. After running in debug mode i found that its trying to drop sequence after dropping table. So get a error ' sequence not exists'.
I am running in a schema named "1", But in public schema it build successfully(not trying to drop sequences).

Here is my ANT target:

<target name="dropAll" depends="prepare" >
    <dropAllDatabaseObjects 
            driver="${db.driver}"
            url="${db.url}"
            username="${db.username}"
            password="${db.password}"
            defaultSchemaName="${db.schema}"
            promptOnNonLocalDatabase="yes"
            classpathref="classpath"
            />      
</target>

Here is the log error:

[dropAllDatabaseObjects] Executing EXECUTE database command: DROP TABLE "1"."database_change_log" CASCADE
[dropAllDatabaseObjects] Executing EXECUTE database command: DROP TABLE "1"."database_change_log_lock" CASCADE
[dropAllDatabaseObjects] Executing EXECUTE database command: DROP TABLE "1"."party" CASCADE
[dropAllDatabaseObjects] Executing EXECUTE database command: DROP SEQUENCE "1"."party_id_seq" CASCADE
[dropAllDatabaseObjects] Release Database Lock
[dropAllDatabaseObjects] Executing UPDATE database command: UPDATE "1".databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID =1
[dropAllDatabaseObjects] Successfully released change log lock

BUILD FAILED
D:\Liquibase 3.3.2-ems\common-model\build.xml:90: Unable to drop all objects from database.
    at   liquibase.integration.ant.DropAllTask.executeWithLiquibaseClassloader(DropAllTask.java:31)
    at liquibase.integration.ant.BaseLiquibaseTask.execute(BaseLiquibaseTask.java:82)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:392)
    at org.apache.tools.ant.Target.performTasks(Target.java:413)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:811)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    Caused by: liquibase.exception.DatabaseException:   org.postgresql.util.PSQLException: ERROR: sequence "party_id_seq" does not exist
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
    at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:112)
    at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:753)
    at liquibase.Liquibase.dropAll(Liquibase.java:743)
    at liquibase.Liquibase.dropAll(Liquibase.java:730)
    at liquibase.integration.ant.DropAllTask.executeWithLiquibaseClassloader(DropAllTask.java:28)
    ... 17 more
   Caused by: org.postgresql.util.PSQLException: ERROR: sequence "party_id_seq"does not exist
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:561)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:405)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:397)
    at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:314)
    ... 24 more

NPE at TableSnapshotGenerator for maven diff

Hi,

When running diff goal i am getting the following exception:


Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.liquibase:liquibase-maven-plugin:3.1.1:diff failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: java.lang.NullPointerException
    at liquibase.ext.hibernate.snapshot.TableSnapshotGenerator.snapshotObject(TableSnapshotGenerator.java:82)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:69)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:131)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:199)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:212)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:158)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:145)
    at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:36)
    at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:24)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:129)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:122)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:110)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:84)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:148)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:377)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:128)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)

Hibernate mappings of spring sessionFactory are ignored

I have a project using Spring and Hibernate. Hibernate persistence is defined into spring bean sessionFactory. I am using xml hibernate mappings instead annotations or JPA.

If I configure referenceUrl property as hibernate:spring:applicationCtx.xml?bean=sessionFactory, liquibase-hibernate find the applicaction context, detects dialect, but it ignores mappings:

[main] INFO liquibase-hibernate - Reading hibernate configuration hibernate:spring:applicationCtx.xml?bean=sessionFactory
Aug 16, 2014 11:22:42 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Aug 16, 2014 11:22:42 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
Aug 16, 2014 11:22:42 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 16, 2014 11:22:42 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 16, 2014 11:22:42 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [applicationCtx.xml]
Aug 16, 2014 11:22:42 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.HSQLDialect
[main] INFO liquibase-hibernate - Using dialect org.hibernate.dialect.HSQLDialect

However, if I create a fake hibernate config file with the same mappings than sessionFactory of application context, it works perfectly with referenceUrl as hibernate:classic:liquibase/fake-hibernate.cfg.xml:

[main] INFO liquibase-hibernate - Reading hibernate configuration hibernate:classic:liquibase/fake-hibernate.cfg.xml
Aug 16, 2014 11:00:34 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
Aug 16, 2014 11:00:34 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.6.Final}
Aug 16, 2014 11:00:34 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Aug 16, 2014 11:00:34 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Aug 16, 2014 11:00:34 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: liquibase/fake-hibernate.cfg.xml
Aug 16, 2014 11:00:34 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: liquibase/fake-hibernate.cfg.xml
Aug 16, 2014 11:00:35 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: es/myapp/infraestructura/model/usrmgt/Log.hbm.xml
Aug 16, 2014 11:00:35 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: es/myapp/infraestructura/model/usrmgt/User.hbm.xml
Aug 16, 2014 11:00:35 AM org.hibernate.cfg.Configuration doConfigure

I am using a custom liquibase-maven-pluging 3.3.0-SNAPSHOT with msvticket's "CORE-1987" patch and liquibase-hibernate 3.4

15 character limit on Primary Key Names?

How can I bypass the 15 character limit on the primary key names that get generated from diffChangeLog?

Doing some debugging, I see that the limit is coming from Hibernate's org.hibernate.sql.Alias class

This causes an issue where I have table with names longer than 15 characters
Ex.
system_setting gets a PK named, system_settinPK

unsub_template
unsub_template_item
get the same PK named, unsub_templatPK

liquibase:diff - Not working (Could not find any META-INF/persistence.xml file in the classpath)

I am getting hard time to run liquibase:diff through liquibase-maven-plugin

Here is the snippet from pom.xml:

            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <propertyFile>target/classes/liquibase.properties</propertyFile>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4</artifactId>
                        <version>${liquibase_hibernate_version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-core</artifactId>
                        <version>${spring.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-context</artifactId>
                        <version>${spring.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-beans</artifactId>
                        <version>${spring.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>${mysql.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-orm</artifactId>
                        <version>${spring.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate-entitymanager.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

Here is the liquibase.properties:

changeLogFile: classpath:/db/changelog/changelog-master.xml
diffChangeLogFile: src/main/resources/db/changelog/changelog-sql-2_0.sql
driver: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/sample
defaultSchema: sample
username: root
password: root
referenceUrl: hibernate:spring:se.sample.core.domain?dialect=org.hibernate.dialect.MySQL5Dialect
verbose: true
dropFirst: false
logging: debug

Here is the maven command that I am using:

mvn resources:resources liquibase:diff -Pprod

And here is the error that I am getting

[INFO] Executing on Database: jdbc:mysql://localhost:3306/sample
INFO 7/30/14 2:47 PM: liquibase-hibernate: Reading hibernate configuration hibernate:spring:se.sample.core.domain?dialect=org.hibernate.dialect.MySQL5Dialect
INFO 7/30/14 2:47 PM: liquibase-hibernate: Found package se.sample.core.domain
INFO 7/30/14 2:47 PM: liquibase-hibernate: Found dialect org.hibernate.dialect.MySQL5Dialect
Jul 30, 2014 2:47:21 PM org.hibernate.jpa.boot.internal.PersistenceXmlParser doResolve
INFO: HHH000318: Could not find any META-INF/persistence.xml file in the classpath
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.192s
[INFO] Finished at: Wed Jul 30 20:20:24 CEST 2014
[INFO] Final Memory: 21M/433M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.2:diff (default-cli) on project fmu-core: Error setting up or running Liquibase: java.lang.NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.2.2:diff (default-cli) on project fmu-core: Error setting up or running Liquibase: java.lang.NullPointerException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: java.lang.NullPointerException
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:371)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: liquibase.exception.DatabaseException: java.lang.NullPointerException
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:53)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:144)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:367)
    ... 22 more
Caused by: java.lang.NullPointerException
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfigurationFromScanning(HibernateSpringDatabase.java:237)
    at liquibase.ext.hibernate.database.HibernateSpringDatabase.buildConfiguration(HibernateSpringDatabase.java:56)
    at liquibase.ext.hibernate.database.HibernateDatabase.setConnection(HibernateDatabase.java:42)
    at liquibase.database.DatabaseFactory.findCorrectDatabaseImplementation(DatabaseFactory.java:123)
    at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
    at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:44)
    ... 24 more
[ERROR] 
[ERROR] 

Since I am using Spring JPA without any persistence.xml so, I can't understand how to make it work.

Can anyone guide please?

Liquibase liquibase-maven-plugin creates tables but tables cannot be found in Integration Tests: org.hibernate.HibernateException

Hi

I am using Liquibase. I want the database tables to be created before the Integration Tests.

The code is located on GitHib: https://github.com/rajivj2/example2/

The EmployeeJpaDAOIT.java is the class that contains the test. All I want to do is have the tables created before the test actually starts. I can see the plugin creates the tables at runtime but the Integration Tests throws the following Exception:

Caused by: org.hibernate.HibernateException: Missing table: employee

I have tried various things but the table cannot be found. Could you please look into what the issue is?

Tests are failing

I checked out the project and tried to do a mvn install so I can use a snapshot from my repository, but had to skip tests to make it happen...

I ignored the 'runMain' test, as there seems to be some mysql db set up for testing in your local network (which, of course, I could not access :))

The tests report is somewhat disturbing (tests run on master branch):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running liquibase.ext.hibernate.snapshot.TableSnapshotGeneratorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.501 sec
Running liquibase.ext.hibernate.database.HibernateEjb3DatabaseTest
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.989 sec <<< FAILURE!
Running liquibase.ext.hibernate.SpringPackageScanningIntegrationTest
Tests run: 3, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 3.774 sec <<< FAILURE!
Running liquibase.ext.hibernate.HibernateIntegrationTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.987 sec
Running liquibase.ext.hibernate.database.connection.HibernateConnectionTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.008 sec
Running liquibase.ext.hibernate.database.HibernateSpringDatabaseTest
Tests run: 4, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.363 sec <<< FAILURE!
Running liquibase.ext.hibernate.database.HibernateClassicDatabaseTest
Tests run: 5, Failures: 0, Errors: 2, Skipped: 1, Time elapsed: 0.279 sec <<< FAILURE!

Results :

Tests in error: 
  ejb3UrlWithNamingStrategy(liquibase.ext.hibernate.database.HibernateEjb3DatabaseTest)
  simpleEjb3Url(liquibase.ext.hibernate.database.HibernateEjb3DatabaseTest)
  hibernateSchemaExport(liquibase.ext.hibernate.SpringPackageScanningIntegrationTest)
  hibernateSchemaUpdate(liquibase.ext.hibernate.SpringPackageScanningIntegrationTest)
  simpleSpringScanningUrl(liquibase.ext.hibernate.database.HibernateSpringDatabaseTest)
  simpleSpringUrl(liquibase.ext.hibernate.database.HibernateSpringDatabaseTest)
  simpleHibernateUrl(liquibase.ext.hibernate.database.HibernateClassicDatabaseTest)
  hibernateUrlWithNamingStrategy(liquibase.ext.hibernate.database.HibernateClassicDatabaseTest)

Tests run: 22, Failures: 0, Errors: 8, Skipped: 1

[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] There are test failures.

Please refer to /home/artur/projects/work/3rdparty/liquibase-hibernate/target/surefire-reports for the individual test results.

I would really like to use this plugin, as writing diffs by hand is a really daunting task... Can I, however, trust this plugin even if its test fail? :)

Best regards,
Artur Gajowy

Project relies on deprecated / removed Hibernate classes

Hi,

Feedback: after spending several hours on making this extension to work from either liquibase standalone or maven plugin and after stepping on a number of land mines, mostly due to non-existant documentation, I have unfortunatelly hit a definitive stopper. That wasn't particularly pleasant ride to be honest...

Problem: liquibase-hibernate4 apparently relies on certain deprecated Hibernate classe(s). Those were deprecated for a while now and with current Hibernate 4.3.0-Final they're not only deprecated but gone. Hence compatibility is broken and this extension doesn't work.

Deprecated class: org.hibernate.ejb.Ejb3Configuration
Located in jar: hibernate-entitymanager-4.3.0.Final.jar
References from Liquibase-Hibernate4:
liquibase.ext.hibernate.database.HibernateSpringDatabase
liquibase.ext.hibernate.database.HibernateEjb3Database
liquibase.ext.hibernate.customfactory.CustomEjb3ConfigurationFactory

There might be other classes affected in a similar way.

http://docs.jboss.org/hibernate/core/4.0/javadocs/org/hibernate/ejb/Ejb3Configuration.html
https://hibernate.atlassian.net/browse/HHH-6182

EDIT: on a positive note - trying again with older Hibernate 4.2.8.Final provided me with more expectable outcome as opposed to previous failfest. That looks promising.

Cheers,
Tomas

Exception when hibernate returns oracle varchar2(n char)

From https://liquibase.jira.com/browse/CORE-1573

Using liquibase-hibernate receives from hbm2dll the type varchar2(50 char) and fails to match against expected pattern. The error is in the pattern in liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.

Example
Maven output extract:

...
liquibase-hibernate: Found table TAREAS
liquibase-hibernate: Found table TAREAS
liquibase-hibernate: Found column idTarea number(10,0)
liquibase-hibernate: Found column codEnt varchar2(50 char)
...
ERROR Failed to execute goal org.liquibase:liquibase-maven-plugin:3.0.7:diff (default-cli) on project intedi-comun: Error setting up or running Liquibase: Unable to find column data type for column codEnt -> Help 1
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.0.7:diff (default-cli) on project intedi-comun: Error setting up or running Liquibase: Unable to find column data type for column codEnt
...
Caused by: liquibase.exception.DatabaseException: Unable to find column data type for column codEnt
at liquibase.ext.hibernate.snapshot.TableSnapshotGenerator.snapshotObjec
t(TableSnapshotGenerator.java:58)
...

endless loop

INFO 3/12/14 8:00 PM:liquibase-hibernate: Could not determine hibernate dialect, using HibernateGenericDialect
Mar 12, 2014 8:00:14 PM org.hibernate.dialect.Dialect
INFO: HHH000400: Using dialect: liquibase.ext.hibernate.database.HibernateGenericDialect
Liquibase diffChangelog Failed: Unknown Reason
SEVERE 3/12/14 8:00 PM:liquibase: Unknown Reason
java.lang.StackOverflowError
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:319)
at liquibase.ext.hibernate.database.HibernateDatabase.getConnectionSchemaName(HibernateDatabase.java:169)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)
at liquibase.ext.hibernate.database.HibernateDatabase.getConnectionSchemaName(HibernateDatabase.java:169)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)
at liquibase.ext.hibernate.database.HibernateDatabase.getConnectionSchemaName(HibernateDatabase.java:169)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)
at liquibase.ext.hibernate.database.HibernateDatabase.getConnectionSchemaName(HibernateDatabase.java:169)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:324)

Exception when hibernate returns oracle varchar2(n char)

The Oracle type varchar2(50 char) fails to match against expected pattern in liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.

'mvn liquibase:diff' output extract:

liquibase-hibernate: Found column codEnt varchar2(50 char) 
[...] 
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.0.7:diff (default-cli) on project intedi-comun: Error setting up or running Liquibase: Unable to find column data type for column codEnt -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.0.7:diff (default-cli) on project intedi-comun: Error setting up or running Liquibase: Unable to find column data type for column codEnt
[...]
Caused by: liquibase.exception.DatabaseException: Unable to find column data type for column codEnt
        at liquibase.ext.hibernate.snapshot.TableSnapshotGenerator.snapshotObject(TableSnapshotGenerator.java:58)
[...]

data type modification not tracked

Changing an enum type to string is not tracked in change sets.

E.g. changing chartType from (default) int ....

@Entity
public class Chart {
    public enum ChartType {
            AREA, AREASPLINE, BAR, COLUMN, LINE, PIE, SCATTER, SPLINE
    }

    @Column(nullable = false, length = 50)
    private ChartType chartType;
}

to string

@Entity
public class Chart {
    public enum ChartType {
            AREA, AREASPLINE, BAR, COLUMN, LINE, PIE, SCATTER, SPLINE
    }

    @Column(nullable = false, length = 50)
    @Enumerated(EnumType.STRING)
    private ChartType chartType;
}

"change set" should be

<modifyDataType
tableName="chart" columnName="chart_type" newDataType="VARCHAR(50)" />

but is empty

┆Issue is synchronized with this Jira Bug by Unito

hibernate4.2-3.3 and hibernate4.2-3.4 'mvn package'

I cannot build packages for releases! I am using 'mvn clean' and 'mvn package' to do so.
For the liquibase (parent .. core ..) sources this command works.


T E S T S

Running liquibase.ext.hibernate.snapshot.TableSnapshotGeneratorTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.436 sec
Running liquibase.ext.hibernate.HibernateIntegrationTest
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 1.468 sec <<< FAILURE!
Running liquibase.ext.hibernate.database.connection.HibernateConnectionTest
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 sec
Running liquibase.ext.hibernate.database.HibernateSpringDatabaseTest
Tests run: 4, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.519 sec <<< FAILURE!
Running liquibase.ext.hibernate.database.HibernateClassicDatabaseTest

Results :

Tests in error:
runGeneratedChangeLog(liquibase.ext.hibernate.HibernateIntegrationTest)
hibernateSchemaExport(liquibase.ext.hibernate.HibernateIntegrationTest)
hibernateSchemaUpdate(liquibase.ext.hibernate.HibernateIntegrationTest)
simpleSpringScanningUrl(liquibase.ext.hibernate.database.HibernateSpringDatabaseTest)
simpleSpringUrl(liquibase.ext.hibernate.database.HibernateSpringDatabaseTest)
simpleHibernateUrl(liquibase.ext.hibernate.database.HibernateClassicDatabaseTest)
hibernateUrlWithNamingStrategy(liquibase.ext.hibernate.database.HibernateClassicDatabaseTest)

Tests run: 12, Failures: 0, Errors: 5, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:06.560s
[INFO] Finished at: Tue Dec 02 12:17:37 CET 2014
[INFO] Final Memory: 21M/103M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project liquibase-hibernate4.2: There are test failures.
[ERROR]
[ERROR] Please refer to /home/synapplix/git/play-modules/liquibase/lib-ext/liquibase-hibernate/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

What are the requirements not met? I try to test and prepare some pull requests but it is not possible to test on release versions? Are there some additional wiki hints?

Liquibase liquibase-maven-plugin creates tables but tables cannot be found in Integration Tests: org.hibernate.HibernateException

Hi

I am using Liquibase. I want the database tables to be created before the Integration Tests.

The code is located on GitHib: https://github.com/rajivj2/example2/

The EmployeeJpaDAOIT.java is the class that contains the test. All I want to do is have the tables created before the test actually starts. I can see the plugin creates the tables at runtime but the Integration Tests throws the following Exception:

Caused by: org.hibernate.HibernateException: Missing table: employee

I have tried various things but the table cannot be found. Could you please look into what the issue is?

┆Issue is synchronized with this Jira Bug by Unito

NPE on PrimaryKeySnapshotGenerator

This issue comes from jhipster/generator-jhipster#754 (comment)

I am using liquibase 3.3.2-SNAPSHOT, and when doing a "mvn compile liquibase:diff" I have the following stacktrace.

In order to reproduce this, you can get my project here:
https://www.dropbox.com/s/33rskcw6y92chii/tmp-mysql.zip?dl=0
It is using MySQL, configuration is in the pom.xml (for the Maven Plugin) and in src/main/resources/config/application-dev.yml (for running the app). You can run the app by typing "mvn spring-boot:run".
And of course you will get the exception when typing "mvn compile liquibase:diff -X"
-> please note that we have another error if we don't call "compile" first, which is another strange issue...

Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.command.CommandExecutionException: java.lang.NullPointerException
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:373)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.execute(LiquibaseDatabaseDiff.java:145)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.NullPointerException
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:123)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:100)
    at org.liquibase.maven.plugins.LiquibaseDatabaseDiff.performLiquibaseTask(LiquibaseDatabaseDiff.java:176)
    at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:369)
    ... 22 more
Caused by: liquibase.command.CommandExecutionException: java.lang.NullPointerException
    at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
    at liquibase.integration.commandline.CommandLineUtils.doDiffToChangeLog(CommandLineUtils.java:121)
    ... 25 more
Caused by: java.lang.NullPointerException
    at liquibase.ext.hibernate.snapshot.PrimaryKeySnapshotGenerator.addTo(PrimaryKeySnapshotGenerator.java:60)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:80)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
    at liquibase.ext.hibernate.snapshot.HibernateSnapshotGenerator.snapshot(HibernateSnapshotGenerator.java:72)
    at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:163)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:241)
    at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:263)
    at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:195)
    at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:177)
    at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:60)
    at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:37)
    at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:25)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:126)
    at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:119)
    at liquibase.command.DiffCommand.createReferenceSnapshot(DiffCommand.java:190)
    at liquibase.command.DiffCommand.createDiffResult(DiffCommand.java:140)
    at liquibase.command.DiffToChangeLogCommand.run(DiffToChangeLogCommand.java:51)
    at liquibase.command.AbstractCommand.execute(AbstractCommand.java:8)
    ... 26 more

@UniqueConstraint is giving null pointer exception

Hi,

I am using Oauth based 2.0 version.I am running mvn pulgin to generate database log for jpa. I am getting null pointer exception when i run below command.

mvn compile liquibase:diff

@table(name = "T_USERRELEATION",uniqueConstraints = @UniqueConstraint(columnNames = { "FROM_USER_ID", "TO_USER_ID" }))

@joincolumn(name = "FROM_USER_ID", nullable = false)
@NotNull
private User fromUser; // (userId)

@JoinColumn(name = "TO_USER_ID", nullable = false)
@NotNull
private User toUser; // (userId)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.