Hibernate映射的三重关系

时间:2012-01-19 16:19:54

标签: hibernate hibernate-mapping

如何映射?

public class Survey {
long id; 
Map<Question, Answer> questionnaire; ...

我想要的是有一张桌子(比如QUESTIONNAIRE) 这将承担三个ID(SURVEY_ID,QUESTION_ID,ANSWER_ID)

1 个答案:

答案 0 :(得分:0)

<map name="questionnaire" table="QUESTIONNAIRE">
  <key column="SURVEY_ID" />
  <index-many-to-many class="...Question" column="QUESTION_ID" />
  <one-to-many class="...Answer" column="ANSWER_ID" />
</map>