title: Hibernate hql - help querying foreign key
body: <p>I am trying to query a foreign key patientId from table appointments.</p>
  
  <p>my Appointment object is mapped to my Patient object (don't know if it matters for the hql) like so:</p>
  
  <pre><code>    &lt;many-to-one name="patient" class="application.model.Patient" fetch="select"&gt;
          &lt;column name="patientId" not-null="true" /&gt;
      &lt;/many-to-one&gt;
  </code></pre>
  
  <p>and my query is: </p>
  
  <pre><code>    createQuery("from Appointment as appt where appt.patientId = 1").list();
  </code></pre>
  
  <p>I have tried to do joins like:</p>
  
  <pre><code>    createQuery("from Appointment as appt join appt.patientId ptid where ptid.patientId = 1").list();
  </code></pre>
  
  <p>I must be missing something fundamental because "appt.appointmentId = 1" works just fine. Any suggestions will be appreciated.</p>