title: How to create criteria in groovy/grails for nested object?
body: <p>I need help on creating hibernate criteria for nested object. For example :</p>
  
  <pre><code>class office{
      Integer id;
      OfficeDetails cmdData ;
  }
  
  class OfficeDetails {
      Integer id;
      Region region;
  
  }
  
  class Region {
      Integer id;
      Integer regionNum;
  }
  </code></pre>
  
  <p>Now, from the service class ( officeService) I am trying to pull up all of the offices that matches a certain region as :</p>
  
  <pre><code>List&lt;Office&gt; findAllByRegion( Integer regionNumber){
      def criteria =  {  eq ( 'cmdData.region.regionNum', regionNumber ) }
      def allOfficesInTheRegion =  Office.findAll(criteria)
  
      return allOfficesInTheRegion
  }
  </code></pre>
  
  <p>Always getting exception :"org.hibernate.QueryException: could not resolve property:"
  I need to find out right way to create criteria for this query.Can anyone help?</p>