Hibernate using JPA (annotated Entities) and liquibase

家住魔仙堡 提交于 2019-11-26 22:21:10

问题


liquibase is a perfect alternative to hibernate's hbm2ddl_auto property if you are using xml-mapping. But Im using JPA annotation (hibernate annotations). Is it possible to use liquibase then?


回答1:


Yes, Liquibase uses hibernate's metadata classes, which are the same whether you use xml mappings or annotations. You do need a hibernate config file to point liquibase to, but your mappings can be xml or jpa annotations. More information can be found at https://github.com/liquibase/liquibase-hibernate/wiki but you can use "database urls" such as

hibernate:classic:com/example/hibernate.cfg.xml

if you have a hibernate xml conf file or

hibernate:ejb3:myPersistenceUnit

if you have a META-INF/persistence.xml, or

hibernate:spring:com.example?dialect=org.hibernate.dialect.MySQL5Dialect

if you would like auto-generate a JPA configuration based on a java package containing annotated Entities.



来源:https://stackoverflow.com/questions/776787/hibernate-using-jpa-annotated-entities-and-liquibase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!