JPA에 엔트리와 코멘트라는 엔티티가 2 개 있습니다. 엔트리는 두 개의 Comment 객체 콜렉션을 포함합니다. 객체JPA에서 같은 유형의 컬렉션 2 개를 얻는 방법?
create table Entry_Comment (Entry_id integer not null, postMortemComments_id integer not null, pmnr integer not null, descriptionComments_id integer not null, dnr integer not null, primary key (Entry_id, dnr), unique (descriptionComments_id), unique (postMortemComments_id))
보관 descriptionComments_id
으로 실패 postMortemComments_id
은 할 수 없습니다
@Entity
public class Entry {
...
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@IndexColumn(base = 1, name = "dnr")
private List<Comment> descriptionComments = new ArrayList<Comment>();
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@IndexColumn(base = 1, name = "pmnr")
private List<Comment> postMortemComments = new ArrayList<Comment>();
...
}
같은 객체를 저장하기 위해, JPA + Hibernate는 "항목"테이블은 테이블 SINGLE "Entry_Comment를", "코멘트"작성 "not null"동시에.
JPA + Hibernate를 사용하여 동일한 유형의 두 개의 콜렉션을 포함하는 객체를 어떻게 저장합니까?
그리고이 관계를 양방향으로 만드는 방법은 무엇입니까? –