title: hibernate criteria API with multiple left inner joins
body: <p>The table relationships is as follows:  </p>
  
  <ul>
  <li>A users table with columns identity, username, age</li>
  <li>An addresses table with columns identity, type, street</li>
  <li>A user_address_associations table with columns identity, userid and addressid. userid has foreign key relationship to users.identity and addressid has foreign key relationsip to addresses.identity.</li>
  </ul>
  
  <p>I will like to select all users older than 18 years with address type set to 1.  Hibernate mappings for User and Address entities exist but there is no associations defined within the mapping from User to Address. The only link between a User and Address is specified via the user_address_associations table.  Also, the User class does not defined an Addresses property.</p>
  
  <p>The raw SQL will be:</p>
  
  <pre><code>select * from users 
  inner join user_address_associations   
  on user_address_associations.userid=users.identity
  inner join addresses 
  on user_address_associations.addressid=addresses.identity and addresses.type=1
  where db.users.age &gt;= 18
  </code></pre>
  
  <p>Using the Hibernate 3.6.5 Criteria API, I started with this:</p>
  
  <pre><code>Criteria criteria = session.createCriteria(User.class);
  
  // how to do the join to addresses table through user_address_associations table?
  
  // where clause
  criteria.add(Restrictions.gt("Age", 1176));
  </code></pre>
  
  <p>Question is, how do I formuate the joins?  </p>