Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate hql-帮助查询外键_Hibernate_Hql - Fatal编程技术网

Hibernate hql-帮助查询外键

Hibernate hql-帮助查询外键,hibernate,hql,Hibernate,Hql,我正在尝试从表约会中查询外键patientId 我的约会对象映射到我的患者对象(不知道这对hql是否重要),如下所示: 我试过做一些类似的事情: createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list(); 我一定错过了一些基本的东西,因为“appt.appointmentId=1”工作得很好。如果您有任何建议,我们将不胜感激。HQL是一种对象查询语言,

我正在尝试从表约会中查询外键patientId

我的约会对象映射到我的患者对象(不知道这对hql是否重要),如下所示:

我试过做一些类似的事情:

    createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list();

我一定错过了一些基本的东西,因为“appt.appointmentId=1”工作得很好。如果您有任何建议,我们将不胜感激。

HQL是一种对象查询语言,由于您有一个引用,您需要首先访问该引用以获取id。假设patient类具有patientid属性

createQuery("from Appointment as appt where appt.patient.patientId = 1").list();
    createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list();
createQuery("from Appointment as appt where appt.patient.patientId = 1").list();