Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a many to many relationship with extra columns in jhipster?

The jhipster doesn't support create many to many relationships with extra fields.

What is the best way to create many to many association with extra columns in jhispter? Should i create a two one-to-many relationship with extra fields?

like image 573
Vítor Nóbrega Avatar asked Jan 29 '16 21:01

Vítor Nóbrega


People also ask

How do you create a many to many relationship in Jhipster?

JHipster UML and JDL Studio If you want to create many entities and relationships, you might prefer to use a graphical tool. In that case, three options are available: JDL Studio, our online tool to create entities and relationships using our domain-specific language.


1 Answers

Using JHipster Domain Language (JDL), a @ManytoMany holding extra properties (columns) can be easily achieved using an association entity and two ManyToOne relationships. See below:

entity Foo{
    ...
}

entity Bar{
    ...
}

entity FooBarAssociation{
    extraProperty1 String
    extraProperty2 String
    ...
}

relationship ManyToOne {
  FooBarAssociation{foo} to Foo{bars}
  FooBarAssociation{bar} to Bar{foos}
}
like image 174
JesusIniesta Avatar answered Sep 29 '22 03:09

JesusIniesta