Translations of this page?:

Hibernate Integration (Since 1.6)

The LiquiBase-Hibernate is a replacement to Hibernate's ”hbm2ddl” functionality.

Advantages of LiquiBase over hbm2ddl

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.

Development Process

Using Hibernate with LiquiBase consists of the following steps:

  1. Make needed changes to your Hibernate-mapped objects
  2. Run diffChangeLog between your Hibernate config file and your development database (see examples below)
  3. Inspect and modify new change sets (if needed)
  4. Update your database with the new changes

Example

Command Line

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 \

Ant

<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>
 
manual/hibernate.txt · Last modified: 2008/07/22 17:33 by 59.167.192.233     Back to top