开发者

Play! - Many to many relationship on same model class

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜