如何修改使用jhipster生成的现有实体? [英] How to modify existing entity generated with jhipster?

查看:431
本文介绍了如何修改使用jhipster生成的现有实体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jhipster发电机来创建一个projet。我已根据 jhipster文档中提供的信息手动生成了一些实体:


$ b $


如果您希望(或需要)手动执行数据库更新,那么这里是开发工作流程:修改您的JPA实体(添加一个字段
关系等)。在
src / main / resources / config / liquibase / changelog目录中创建一个新的更改日志。
目录中的文件以其创建日期(以yyyyMMddHHmmss
格式)为前缀,然后有一个标题描述它们的作用。例如,
20141006152300_added_price_to_product.xml是个好名字。在您的
src / main / resources / config / liquibase / master.xml文件中添加这个
更改日志文件,以便下次运行应用程序时应用
如果您想要有关
使用Liquibase的更多信息,请访问 http://www.liquibase.org


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

谢谢

解决方案

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

 < jhipster_root_folder> /。jhipster / entityName.json 

2)构建代码


$ b $ 3)在项目的根目录下运行命令:

  yo jhipster:entity entityName 

注意:此命令默认覆盖您的所有手动更改。我建议在运行此命令之前先对VCS存储库进行提交,以最终还原任何不需要的更改。



4)运行

  mvn liquibase:diff 


I use jhipster generator to create a projet. I've generated some entity manually following the information provided in 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.

Here the documentation just mention, how to add!!! What to do if i want to delete a field or a relation between entities (jpa entity) ?

Thanks

解决方案

1) Edit the json file representing your entity (add/remove field, the syntax is pretty easy, check in the end of the file if is required any change to the general entity properties like 'fieldsContainOneToMany'...), you'll find it in:

<jhipster_root_folder>/.jhipster/entityName.json

2) Build the code.

3) In the root of your project run the command:

yo jhipster:entity entityName

NOTE: this command by default overwrite all your manual changes. I recommend to do a commit on a VCS repository before to run this command to eventually revert any not required change.

4) run

mvn liquibase:diff

这篇关于如何修改使用jhipster生成的现有实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆