Mapping Files Not Specified in hibernate.cfg.xml

I am trying to migrate my current Hibernate->DB diff approach from using hbm2ddl to using Liquibase’s diff function.

Currently, my ant build file looks like this:

You’ll notice that I am not specifying my mapping files via my hibernate configuration, rather I’m specifying a fileset for hbm2dll to process.  We do not currently use a hibernate configuration file in our application as we use spring to wildcard-search for our hbms.  The only reason why I have a hibernate configuration specified in this ant task is so I can specify the database\user\password to match against.

Is there any way to execute liquibase’s diffDatabaseToChangeLog task in a similar way?

Thanks!

Unfortunately not at this point.  I am hoping to have some time to improve the hibernate diff support for the 2.1 release.  The diff tool for hibernate is based on hbm2ddl so if you can get an instance of hbm2ddl you should be able to pass it to the hibernate diff tool some way.  If you wanted to take a look at it and commit a patch, that would be great.  Otherwise I’m hoping to have 2.1 out by the end of the year.

Nathan

If you are still interested in testing diff-database on liquibase, I recomend the next (this is that I do):

and:

The diffDatabaseToChangeLog has a problem that I forget to indicate in the forum and it is that baseUrl attribute does not admit absolute path, or at least if you put the “liquibase:” indication before the path.

Of course, sfproperty are not neccesary if you use diffDatabaseToChangelog because you have to put explicitly the database properties as task attributes. Liquibase does not catch the sfproperties from hibernate configuration file.

Liquibase diff-database has good things but it fails in comparation to update hibernate tool in, at least, two important questions:

  • Liquibase does not support userTypes.
  • Liquibase gets mixed-up with existant foreign keys in the database and it writes drop and create tags for the same foreign key in the same file or it simply writes FKs create tag to already existant FKs in the db.

Thanks for the test cases.  I’ll add them to the feature request