java - 如何修改使用 jhipster 生成的现有实体?

标签 java hibernate jpa jhipster

我使用 jhipster 生成器来创建一个项目。我根据 jhipster documentation 中提供的信息手动生成了一些实体。 :

If you prefer (or need) to do a database update manually, here is the development workflow: Modify your JPA entity (add a field, a relationship, etc.) Create a new "change log" in your src/main/resources/config/liquibase/changelog directory. The files in that directory are prefixed by their creation date (in yyyyMMddHHmmss format), and then have a title describing what they do. For example, 20141006152300_added_price_to_product.xml is a good name. Add this "change log" file in your src/main/resources/config/liquibase/master.xml file, so it is applied the next time you run your application If you want more information on using Liquibase, please go to http://www.liquibase.org.

这里的文档刚刚提到,如何添加!!! 如果我想删除一个字段或实体之间的关系(jpa 实体)怎么办?

谢谢

最佳答案

1) 编辑代表您的实体的 json 文件(添加/删除字段,语法非常简单,如果需要对“fieldsContainOneToMany”等一般实体属性进行任何更改,请检查文件末尾...),您可以在以下位置找到它:

<jhipster_root_folder>/.jhipster/entityName.json

2) 构建代码。

3) 在项目的根目录中运行命令:

yo jhipster:entity entityName

注意:默认情况下,此命令会覆盖您的所有手动更改。我建议在运行此命令之前在 VCS 存储库上进行提交,以最终恢复任何不需要的更改。

4) 运行

mvn liquibase:diff

关于java - 如何修改使用 jhipster 生成的现有实体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28216307/

相关文章:

java - 在选定执行时跳过父类中的 gson 字段

java - JPA 投影获取结果但未将列与界面 View 中的方法匹配

Java JPA - 从在第二次运行时不起作用的实体创建表

java - JPA2 : @Min constraint for float

java - 无法运行程序,错误=7,参数列表太长

java - Spring批处理2.2 JavaConfig

java - 如何显示带有MySQL表路径的图像?

java - hibernate 与缓存的连接过多

mysql - 使用 hibernate 登录失败 servlet

java - 尝试调用 JPA 函数时出现语法错误