ExamResult
클래스에는 부모 클래스 인 Exam
에 대한 링크가 있습니다.Hibernate - 관련 속성에 의한 필터링
시험 결과에 부울 속성으로 필터링하고 싶습니다.
List<ExamResult> examResults = session
.createCriteria(ExamResult.class)
.createCriteria("exam") // 3.
.add(Restrictions.eq("primaryExam", Boolean.TRUE)) // 4.
.list();
줄 3과 4를 추가하지 않고도 모든 행을 올바르게 검색 할 수 있습니다. 이 추가 라인을 사용하면 다음과 같은 오류가 발생합니다.
org.hibernate.QueryException: not an association: exam
나는 올바른 방향으로 가고 있는지 확실하지 않습니다. hibernate tutorial은 나에게 불명확하다.
내가 사용한 관계는 this tutorial에서 볼 수 있습니다.
ExamResult가 있습니다
@Column(name="exam_id", nullable=false)
private Exam exam;
그렇지 않으면 기준 :
// bidirectional association! Needed to trick hibernate ;P
@Column(name="exam_id", nullable=false, updatable=false, insertable=false)
private Long exam;
시험는 문제가 ExamResult
지도에서이 있어야 할 것입니다
//----bidirectional association
@OneToMany(mappedBy="exam")
private final List<ExamResult> examResults = new ArrayList<ExamResult>();
튜토리얼을 사용하고 있더라도 실제 매핑을 보여줄 수 있도록 모든 사람이이를 볼 수 있습니까? :) 감사! –
@Arthur Thomas - 관련 협회와 함께 업데이트했습니다. – Pool