Reputation: 636
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.
Upvotes: 11
Views: 13845
Reputation: 73
Maybe you want to add skipServer to your JDL, there's 2 ways of doing it:
skipServer all except entity1, entity2
This aproach will skip the server-side code of all entities except entity1 and entity2
skipServer entity1, entity2
And this one will skip the code of only entity1 and entity2.
I reccomend the first one since you can ignore all entities except the ones you are willing to re-generate (User and Company). You may also add skipClient to prevent changes to the front-end (same syntax).
Observations:
skipServer all except User
This will create the relationship only in User since the code from Company is begin skipped.
Also there's a bug where removing skipServer and skipClient from your JDL don't remove them from .jhipster/entity.json, so you will have to go there and delete the line manually.
Upvotes: 0
Reputation: 386
I already had such problem, resolved it by creating an additional entity with one-to-one relationship to user, like that:
entity Company
entity UserProfile
relationship OneToOne {
UserProfile{user} to User
}
relationship ManyToOne {
UserProfile{company} to Company
}
hope, this will help you
Upvotes: 1
Reputation: 125
How about this: jdl-snippet
entity Company {
name String required
}
relationship OneToMany {
User{company} to Company
}
Upvotes: -1
Reputation: 3010
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?
Upvotes: 10