Play! framework: ManyToMany relation

Thanks to this post, a clear explaination about how to specify a Many-to-many relation between 2 entities with a <master> and <slaves>.

When you map a same "ManyToMany relationShip" in both directions, you??
need to tell which of these two directions is (kind of) the "master".??
So : one of your @ManyToMany annotations must have the info :??
"mappedBy" :??

For example : if you have two entities : "Event" and "User", and a??
User can "follow" several "Events",??
and an Event can be followed by several Users ("ManyToMany??

You would have :??

in the entity User :??
?? ?? public Set<Event> followedEvents = new HashSet<Event>();??

in the entity Event :??
?? ?? public Set<User> followsByUsers = new HashSet<User>();??

Thanks to Dam74 !

3 commentaires sur “Play! framework: ManyToMany relation

  1. Thank you! I just switched form RoR to Play!Framework and spend some time to make valid relations. All was done but Many-To-Many. All my tests failed. After your description tests are green. Thank you.

Les commentaires sont fermés.

Créez un site Web ou un blog gratuitement sur

Retour en haut ↑

%d blogueurs aiment cette page :