The LiquiBase-Hibernate is a replacement to Hibernate's ”hbm2ddl” functionality.
While hbm2ddl works in general, it is basically a database diff tool and therefore has all the problems associated with database diff tools.
The LiquiBase-Hibernate integration records the database changes required by your current Hibernate mapping to a change log file which you can then inspect and modify as needed before executing.
Using Hibernate with LiquiBase consists of the following steps:
liquibase \
--driver=oracle.jdbc.OracleDriver \
--classpath=jdbcdriver.jar:hibernate.jar \
--url=jdbc:oracle:thin:@localhost:1521:oracle \
--username=scott \
--password=tiger \
--changeLogFile=path/to/changelog \
diffChangeLog \
--baseUrl=hibernate:YOUR_HIBERNATE.CFG.XML \
: The above code should actually read like this:
liquibase \
--classpath=jdbcdriver.jar:hibernate.jar \
--changeLogFile=path/to/changelog \
--url=hibernate:YOUR_HIBERNATE.CFG.XML \
diffChangeLog \
--baseDriver=oracle.jdbc.OracleDriver \
--baseUrl=jdbc:oracle:thin:@localhost:1521:oracle \
--baseUsername=scott \
--basePassword=tiger
<target name="hibernate-update" depends="prepare"> <taskdef resource="liquibasetasks.properties"> <classpath refid="classpath"/> </taskdef> <diffDatabaseToChangeLog driver="${database.driver}" url="${database.url}" username="${database.username}" password="${database.password}" baseUrl="hibernate:YOUR_HIBERNATE.CFG.XML" outputFile="path/to/changelog.xml" classpathref="classpath" > </diffDatabaseToChangeLog> </target>