简体   繁体   English

在 SQL 内省生成的 Hibernate 类上使用 Liquibase

[英]Use Liquibase on SQL introspection generated Hibernate classes

I would like to know if I can easily use Liquibase on SQL introspection generated Hibernate classes.我想知道是否可以在 SQL 内省生成的 Hibernate 类上轻松使用 Liquibase。 I inherited a Spring 4, Hibernate 5 project and am somewhat unfamiliar with Java Hibernate best practices.我继承了一个 Spring 4、Hibernate 5 项目,并且对 Java Hibernate 最佳实践有些陌生。

All the entity classes seem to be generated from hbm2java by SQL inspection.所有实体类似乎都是通过 SQL 检查从 hbm2java 生成的。 This is inferred by an absence of any hibernate mapping files, but hbm2java created all entity files.这是因为没有任何休眠映射文件,但 hbm2java 创建了所有实体文件。

I would like to keep the directionality that entity classes are generated by the databases, but have schema migrations owned by the application through Liquibase or similar.我想保持实体类由数据库生成的方向性,但通过 Liquibase 或类似方法拥有应用程序拥有的模式迁移。 Is this an easy pattern to achieve.这是一个容易实现的模式吗?

Yes, I use two maven goals in process-resources phase.是的,我在process-resources阶段使用了两个 Maven 目标。

  1. Liquibase Liquibase
  2. Hibernate hbm2java休眠 hbm2java

I tried hsqldb on target/mydatabase unfortunately if the first goal (liquibase) finished its not flushed to the file and the second goal has a empty database.不幸的是,如果第一个目标(liquibase)完成它没有刷新到文件并且第二个目标有一个空数据库,我在target/mydatabase我的数据库上尝试了 hsqldb 。 Finally i use h2database on jdbc:h2:file:./target/mydatabase... .最后我在jdbc:h2:file:./target/mydatabase...上使用 h2database。 It works like a charm.它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM