我的Play中有一个简单的模型类!应用程序:
@Entity
public class User extends Model {
public String login;
public String password;
public String fullName;
public Date lastLogin;
public List<User> following;
public List<User> followedBy;
}
如何正确地注释和/或修改此类,以便能够获取当前用户正在关注的用户并获取跟随当前用户的用户?
答案 0 :(得分:3)
应该如此简单:
@Entity
public class User extends Model {
public String login;
public String password;
public String fullName;
public Date lastLogin;
@ManyToMany(mappedBy = "followedBy") public List<User> following;
@ManyToMany public List<User> followedBy;
}