jhipster: How to create a one-to-many relationship

2019-06-22 01:39发布

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.

标签: jhipster
2条回答
欢心
2楼-- · 2019-06-22 02:23

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?

查看更多
Emotional °昔
3楼-- · 2019-06-22 02:29

How about this: jdl-snippet

entity Company {
    name String required
}
relationship OneToMany {
    User{company} to Company
}
查看更多
登录 后发表回答