2

I am developing an app using the Jhipster. In my domain design I have five relationships with the User entity. I don't understand why the Jhipster does not allow relationships from it. I have changed the design so it counts with ManyToOne relationships etc. to avoid changing the User entity, but there is one relationship I cannot change - User is resident of a Flat, Flat has multiple residents.

I can adjust the generated entities and related files by hand, but that can produce problems in the future, when I would like to change the domain and wanted to use the jhipster tools (jhipster-uml, yo jhipster:entity)

My question is - is there a way of creating such OneToMany relationship with the pre-generated User entity using supplied jhipster tools?

I have read the related stackoverflow questions (1, 2), but that did not help very much.

Jhipster version 3.1.0, jhipster-uml version 1.6.5. My domain design in JDL is avalaible at GitHub.

Community
  • 1
  • 1
Tony
  • 1,057
  • 8
  • 14

1 Answers1

0

One work-around may be to create a separate object for the relationship, and use the fact that all entities have the "createdBy" attribute.

entity Residency {

}

relationship ManyToMany {
    Flat{resident} to Residency{flat(name)}
}

Then make the user create a Residency object, manually or automatically on signup or whatever you need.

Now you can search for all Residencies for specific User or all Residents of a specific flat, just by using normal Spring Data queries using createdBy column.

JavaDevSweden
  • 2,154
  • 2
  • 18
  • 29