i'm implementing an jboss seam application and i want to map a buddy list in JPA (Hibernate Entity Manager).
1 user can have N buddies that are other users, so i have now something similar to this:
Code:
@Entity
class User
{
@OneToMany(mappedBy="user")
private Set<User> = new HashSet<User>(0);
}
and
Code:
public Enum BuddyStatus
{
CONFIRMED, AWAITING_APPROVAL, BLOCKED
}
and
Code:
@Entity
class Buddy
{
// the user
@ManyToOne
private User user;
// the user
private User buddy;
private BuddyStatus status;
}
i have doubts about this implementation. this mean that if i want to block a user, it must be in the buddy set with the blocked state (mixing friends and enemies in the same "bag").
Also i dont know how to map this situation, if it's really an 1-M or an M-N.
Help please?