jhipster: How to create a one-to-many relationship with user entity?

♀尐吖头ヾ 提交于 2019-12-10 13:51:00

问题


I have created my domain using jhipster-uml JDL script. Now I want to establish a O2M from User to an an existing entity (company). Is there a way to do that via a JDL script? The script would need to re-declare every entity the relationship needs. But these are existing entities, is there a switch to direct jhipster-uml to use the existing domain definition without the need to re-declare it again?

I just want to avoid using the Liquibase/Java manual setup.


回答1:


In the 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.

It seems only many-to-one relations can be generated with the User entity via the sub-generator. I don't know the UML tool but I guess it just use subgenerators under the hood.

You might need to do the relation manually

See also In JHipster how to create entity with relationship with User?




回答2:


How about this: jdl-snippet

entity Company {
    name String required
}
relationship OneToMany {
    User{company} to Company
}


来源:https://stackoverflow.com/questions/35810441/jhipster-how-to-create-a-one-to-many-relationship-with-user-entity

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!