I have a simple model 开发者_Python百科class in my Play! application:
@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;
}
How to properly annotate and/or modify this class to be able to fetch users that current user is following and fetch users that are following current user?
Should be as simple as:
@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;
}
精彩评论