JPAで問題が発生しています。ユーザーが他のユーザーをフォローし、フォローされることを可能にするデータベースを実装しようとしています。私は次のようなものが(要約して)必要だと思います:
USER_TABLE: id | userName
RELATIONSHIP_TABLE: id | follower | followed | acceptation
私は2つのエンティティを持っています(これも要約されています):
@Entity
public class User implements Serializable {
@Id
private Long id;
private String userName;
@OneToMany
private Collection<Relationship> followings;
}
@Entity
public class Relationship implements Serializable {
@Id
private Long id;
private User follower;
private User followed;
private boolean accepted;
}
私の問題は、必要な 2 つよりも多くのテーブルを取得するため、これが可能かどうかわからないことです。
誰でも私を助けることができますか?私の英語に感謝し、申し訳ありません。