日期:2014-05-17 浏览次数:20703 次
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(
name="xz_forfriend" ,
joinColumns={@JoinColumn(name="uid")} ,
inverseJoinColumns={@JoinColumn(name="fid")}
)
public Set<User> getForfriends() {
return forfriends;
}
public void setForfriends(Set<User> forfriends) {
this.forfriends = forfriends;
}
User uuser = userDao.getUser(uid);
User fuser = userDao.getUser(fid);
//单向添加即可
uuser.getForfriends().add(fuser);
userDao.save(fuser);