简体   繁体   English

如何正确扩展JHipster用户实体

[英]How to properly extend JHipster User Entity

I started a new JHipster project recently and I have a requirement in the project for extending a built-in User entity. 我最近开始了一个新的JHipster项目,我在项目中要求扩展内置的User实体。

For example to add some new attributes (and columns in the database to persist those). 例如,添加一些新属性(以及数据库中的列以保留这些属性)。 But, since this is built-in functionality and the User entity is not listed in .jhipster folder I'm wandering of a proper way to do it. 但是,由于这是内置功能,并且用户实体未列在.jhipster文件夹中,我正在以适当的方式徘徊。

The simplest option would be to change User.java and liquibase migration xmls and all associated files but that would probably be an obstacle for future jhipster upgrades (running yo jhipster inside project folder like it is explained here jhipster docs ). 最简单的选择是更改User.java和liquibase迁移xmls以及所有相关文件,但这可能会成为未来jhipster升级的障碍(在项目文件夹中运行yo jhipster就像在这里解释jhipster docs一样 )。 Another possible route could probably be to create a new entity which would be in a one-to-one relation to the User entity, but I'm not sure how to exactly do this: Using yo jhipster:entity or ? 另一种可能的路径可能是创建一个与User实体一对一关系的新实体,但我不确定如何做到这一点:使用yo jhipster:entity或?

Has anyone successfully done this previously? 有没有人以前成功完成过这个? What are the best practices I should follow in this case? 在这种情况下我应该遵循哪些最佳做法?

Easiest solution to be able to easily follow JHipster upgrades is to create a new entity (eg UserExtraInfo) with a one-to-one relationship with User and the owner of the relationship should be the new entity as we don't want to modify User. 能够轻松遵循JHipster升级的最简单的解决方案是创建一个与User具有一对一关系的新实体(例如UserExtraInfo),并且该关系的所有者应该是新实体,因为我们不想修改User 。 You'd generate the new entity using yo jhipster:entity . 您将使用yo jhipster:entity生成新yo jhipster:entity

Due to a related issue you must use release JHipster 3.5.0 at least to get this working. 由于相关问题,您必须至少使用版本JHipster 3.5.0来实现此功能。

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

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