我思考这个问题的时候,头脑开始感到疼痛,难道它就是这么简单吗:
@ManyToMany(mappedBy = "following", cascade = CascadeType.ALL)
private Set<User> followers = new HashSet<User>();
@ManyToMany(mappedBy = "followers", cascade = CascadeType.ALL)
private Set<User> following = new HashSet<User>();
CascadeType.ALL
是一种代码异味。 - István Békési