I was working on problem where we have a many to many relationship. The table structure looks like :-
User Table :-
A many to many relationship in user and event table so we have table (used mapped by so only one table)
Now requirement is to create a Team which consist of multiple users registering for a single event(Team cannot register for same event multiple times). Every event will not have the same team(Teams are created on event Basis). There are multiple teams in one event. Every user can be part of only one team per event but he can participate in multiple events but he can participate in one event only one time from certain team.
How can this relationship be created with Hibernate ??
Off course, we will create a new table Team with team_id but to relate
I was thinking of using composite key form event_user table and add the team_id to Event_User. I dont have any pojo for Event_User as it is a autogenerated table by Hibernate ...how can we add this relationship. Any sample code will really help.
Note currently we are using annotations in Hibernate