That is a known bug. It is fixed in the repository now and will probably have a new build containing it next week.
Nathan
Hi,
I’m slowly working my way though integrating Liquibase, Hibernate, Spring and the Maven and I’ve stumbled onto what I believe is a bug in the liquibase-hibernate extension in the TableSnapshotGenerator class. It looks like that when iterating through the columns we attempt to build the collection of primary keys. The problem is that the first time through we attempt to set the name of the PrimaryKey to the table.getPrimaryKey.getName() (line 82) which has not be set yet. This results in the crowd favorite NPE. I’m not exactly certain the intent here is I thought I’d bring it to the attention of folks. Stack trace and snippet follow:
-
- INFO 2/28/14 1:53 PM:liquibase-hibernate: Found table summary
- INFO 2/28/14 1:53 PM:liquibase-hibernate: Found column id bigint
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD FAILURE
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 6.794s
- [INFO] Finished at: Fri Feb 28 13:53:59 PST 2014
- [INFO] Final Memory: 14M/313M
- [INFO] ------------------------------------------------------------------------
- [ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (default-cli) on project nigg_fair: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:3.1.1:diff failed. NullPointerException -> [Help 1]
- org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (default-cli) on project my_project: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:3.1.1:diff failed.
-
- protected DatabaseObject snapshotObject(DatabaseObject example, DatabaseSnapshot snapshot) throws DatabaseException, InvalidExampleException {
- ...
- // line 69
-
- org.hibernate.mapping.PrimaryKey hibernatePrimaryKey = hibernateTable.getPrimaryKey();
- if (hibernatePrimaryKey != null) {
- boolean isPrimaryKeyColumn = false;
- for (org.hibernate.mapping.Column pkColumn : (List) hibernatePrimaryKey.getColumns()) {
- if (pkColumn.getName().equals(hibernateColumn.getName())) {
- isPrimaryKeyColumn = true;
- break;
- }
- }
- if (isPrimaryKeyColumn) {
- if (primaryKey == null) {
- primaryKey = new PrimaryKey();
- // line 82 - ?
- primaryKey.setName(table.getPrimaryKey().getName());
- }
- primaryKey.addColumnName(pkColumnPosition++, column.getName());
- Value value = hibernateColumn.getValue();
-