I am confusing how to design a OOP model for FAN and FOLLOW, just like the FRIEND and FOLLOW IN facebook.
My design:
Code:
@Entity
public class Person{
@Id
private String personId;
@OneToMany(mappedBy="person")
private Set<Follow> followSet;
.....
}
Code:
@Entity
public class Follow {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long followId;
@ManyToOne(optional=false)
private Person person;
@OneToOne(optional=false)
private Person following;
.....
}
The disadvantage is that I cannot get the SET of FAN easily.
But Is it really necessary for the relationship to design two sort of SET? (fanSet followSet)