3
我想从表约会中查询外键的patientId。Hibernate hql - 帮助查询外键
我的约会对象映射到我的病人对象(不知道这是否事项的HQL),像这样:
<many-to-one name="patient" class="application.model.Patient" fetch="select">
<column name="patientId" not-null="true" />
</many-to-one>
和我的查询是:
createQuery("from Appointment as appt where appt.patientId = 1").list();
我曾尝试做加盟,如:
createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list();
我必须失去了一些基本的东西,因为“appt.appointmentId = 1”的作品就好了。任何建议将不胜感激。