与用户的 OneToMany 关系
OneToMany relationship with User
我刚刚用代码生成器开始了一个项目"Jhipster"。我正在尝试与 "User" 关系建立 OneToMany 关系。我已经看过很多主题,但找不到任何有效的答案。你有什么想法?我什至尝试过一段中间关系,但没有任何效果。
非常感谢。
您可以在模型实体和特殊实体用户之间创建关系。但是你必须考虑到这个实体的限制。正如它出现在 JHipster documentation:
Tip: the User entity
Please note that the User entity, which is handled by JHipster, is
specific. You can do:
many-to-one relationships to this entity (a Car can have a many-to-one relationship to a User). This will generate a specific
query in your new entity repository, so you can filter your entity on
the current security user, which is a common requirement. On the
generated Angular/React client UI you will have a dropdown in Car to
select a User.
many-to-many and one-to-one relationships to the User entity, but the other entity must be the owner of the relationship (a Team can
have a many-to-many relationship to User, but only the team can
add/remove users, and a user cannot add/remove a team). On the
Angular/React client UI, you will also be able to select a User in a
multi-select box.
When using the UAA authentication type, you can only create
relationships to the User entity if the related entity is also within
the UAA microservice.
我刚刚用代码生成器开始了一个项目"Jhipster"。我正在尝试与 "User" 关系建立 OneToMany 关系。我已经看过很多主题,但找不到任何有效的答案。你有什么想法?我什至尝试过一段中间关系,但没有任何效果。
非常感谢。
您可以在模型实体和特殊实体用户之间创建关系。但是你必须考虑到这个实体的限制。正如它出现在 JHipster documentation:
Tip: the User entity
Please note that the User entity, which is handled by JHipster, is specific. You can do:
many-to-one relationships to this entity (a Car can have a many-to-one relationship to a User). This will generate a specific query in your new entity repository, so you can filter your entity on the current security user, which is a common requirement. On the generated Angular/React client UI you will have a dropdown in Car to select a User.
many-to-many and one-to-one relationships to the User entity, but the other entity must be the owner of the relationship (a Team can have a many-to-many relationship to User, but only the team can add/remove users, and a user cannot add/remove a team). On the Angular/React client UI, you will also be able to select a User in a multi-select box.
When using the UAA authentication type, you can only create relationships to the User entity if the related entity is also within the UAA microservice.