Hibernate hql - foreign key query
I am trying to query a foreign key client for an id from a table.
my Assignment object maps to my Patient object (don't know if it matters for hql):
<many-to-one name="patient" class="application.model.Patient" fetch="select">
<column name="patientId" not-null="true" />
</many-to-one>
and my request:
createQuery("from Appointment as appt where appt.patientId = 1").list();
I tried to do joins like:
createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list();
I must be missing something fundamental because "appt.appointmentId = 1" works just fine. Any suggestions would be appreciated.
+3
source to share