title: Generic DAO and nested properties support
body: <p>I am trying to perform a DB access through a DAO object, and I have bumped into the case where I need to query a field in another Entity.</p>
  
  <p>Considering two entities (EntityA and EntityB) that are connected in entity A through the foreign key <code>EntityA.idEntityB</code>.</p>
  
  <p>I have <code>GenericDao&lt;EntityA&gt; daoA</code> and I am trying to get all the results that match a determined field of EntityB: <code>idEntityB.fieldOfB</code> all in the same <em>find</em> method of the dao. </p>
  
  <p>Is it possible? And if so some directions would be nice. Thanks</p>
  
  <p><strong>edit</strong></p>
  
  <p>An example of my code: </p>
  
  <h3>Entities</h3>
  
  <pre><code>public class EntityA {
      @JoinColumn(name = "id_entity_b", referencedColumnName = "id")
      @ManyToOne(optional = false, fetch = FetchType.EAGER)
      private EntityB idEntityB;
      // getter+setter...
  }
  
  public class EntityB {
      // ...
      private String fieldOfB;
      // getter+setter...
  }
  </code></pre>
  
  <h3>DAO Access</h3>
  
  <pre><code>GenericDao&lt;EntityA&gt; daoA = // ...
  
  Set&lt;Criterion&gt; filter = new HashSet&lt;Criterion&gt;();
  filter.add(Restrictions.eq("idEntityB.fieldOfB"));
  
  List&lt;EntityA&gt; list = dao.findByFilter(filter);
  </code></pre>
  
  <p>The error message is something like "<em>Could not resolve property idEntityB.fieldOfB</em>"</p>
  
  <p><strong>edit 2</strong></p>
  
  <p>I was able to find something like what I want to do. Although my API is slightly different I believe this is helful for anyone who gets across this problem at an early stage of their own project.</p>
  
  <p><a href="http://code.google.com/p/hibernate-generic-dao/" rel="nofollow">http://code.google.com/p/hibernate-generic-dao/</a></p>
  
  <blockquote>
    <p>The framework features a powerful and flexible search functionality.
    This is used by passing a search object to search methods on general
    and generic DAOs.</p>
  </blockquote>
  
  <p>Searches with nested properties are fully supported in this project.</p>