Reputation: 1137
I need to implement user invitations and i have a little problem with mapping entities. I have User entity which have set of invitations and a invitation have User field and inviting User field. In this way I have two User fields that are the same.
User side:
@OneToMany(mappedBy="user")
public Set<Invitation> invitations;
Invitation:
@ManyToOne
@JoinColumn(name="idInvitingUser", insertable=false, updatable=false)
public User invitingUser;
@ManyToOne
@JoinColumn(name="idUser")
public User user;
How can I map this proper ?
Upvotes: 0
Views: 55
Reputation: 32831
I guess you will need two sets of invitations on the user side: invitations sent and invitations received.
UPDATE:
@OneToMany(mappedBy="user")
public Set<Invitation> invitations;
@OneToMany(mappedBy="invitingUser")
public Set<Invitation> invitationsSent;
Upvotes: 1