开发者

How to create Liquibase Change Log file for new tables?

开发者 https://www.devze.com 2023-04-03 16:19 出处:网络
I am using Hibernate 2 + Spring 3 + Liquibase 1.9. I have created my entity classes using Hibernate annotation as normal

I am using Hibernate 2 + Spring 3 + Liquibase 1.9. I have created my entity classes using Hibernate annotation as normal Now I want to generate the Liquibase change log automatically which should contain the DB CREATE statements. I don't want to manually create the change log XML files as it feels tedious and error prone especially for the first time.

What puzzles me is that there is no maven goal on maven开发者_开发技巧 to look at mt entity classes and generate the Liquibase change log in a similar fashion to what hbm2ddl does?

I Googled numerous pages with no avail, they seem to point me to a Liquibase command line and some ANT script, but it should be possible on maven!

So I guess my question is: How to invoke a process to generate Liquibase change log for new entity classes written in JPA annotation?

Thanks


At this point, the liquibase/hibernate integration does not support JPA annotations for hibernate comparison.

When the hibernate integration does support JPA, you will still want to make sure that the generated changeSets actually match what you expect, since any database diff tools do not understand the intent of the change (see http://blog.liquibase.org/2007/06/the-problem-with-database-diffs.html). For that reason, I tend to just write the changeSets by hand from the start.


I ran into the same issue and solved it by first creating the database using hibernate hbm2ddl (set hibernate.hbm2ddl.auto to create or update), followed by the liquibase generateChangeLog command against the generated database.

0

精彩评论

暂无评论...
验证码 换一张
取 消