Hibernate 多对一 实体匹配

来源:百度知道 编辑:UC知道 时间:2024/06/17 13:03:29
实体类:
public class Question {
private int Q_ID;
private employee employee;
private Questionaire questionaire;
private String Q_type;
private String Q_Des ;
private String Q_option1;
private String Q_option2;
private String Q_option3 ;
private int Q_stc1 ;
private int Q_stc2 ;
private int Q_stc3 ;
getter and setter...
}

public class Questionaire {
private String Qus_ID;
private String Qus_type;
private String Qus_Des;
getter and setter...
}

XML:

<class name="Data.tables.beans.Question" table="Question">
<id name="Q_ID" column="Q_ID">
<generator class="increment"/>
</id>
<property name="Q_type"/>
<property name="Q_Des"/>
<property name="Q_option1"/>
<property name="Q_option2"/>
<proper

昨天已经回答过一次了,你还没有结贴...
已经跟你说过了,你的Question类(不是表)里没有Qus_ID,所以,你的q.Qus_ID怎么还一直这么写着?难道我的回答就这么不起眼?你的Qus_ID已经被封装成了Questionaire了,所以可能是这么用的
from Questionaire as qu,Question as q where qu.Qus_ID='1' AND qu.Qus_ID=q.questionaire.Qus_ID;
再试试吧.