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

Ajouter un commentaire

  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.

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l'aide de votre compte Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

Propulsé par

Retour en haut ↑

%d blogueurs aiment cette page :