title: Hibernate query a foreign key field with ID
body: <p>For example, I have two entities: Employee and Address. Of these enitities, Employee has a foreign key AddressID references the ID column on Address. In the Java domain objects, Hibernate nicely wraps the forgein key integer field with a Address object field. But now, how could I query the Employee with a certain AddressID? </p>
  
  <p>I have tried to create a table alias. That seems to work, but it is fairly awkward. </p>
  
  <p>I had also tried to do something like this: </p>
  
  <pre><code>criteria.add(restriction.eq("TheAddressObjectFieldName", 123);
  </code></pre>
  
  <p>It works some time but not always. I am not sure this is the right way, but I was hoping it could all the time. </p>
  
  <p>So what is the right way to query on a foreign key column in hibernate? </p>