title: Hibernate sort by properties of inner bean?
body: <p>In my domain model I have following Classes.A 'UserProfile' has one 'SecurityPrincipal'</p>
  
  <pre><code>class SecurityPrincipal{
   private String loginId;
   private String password;
   private Date registeredData;
   private int status;
  }
  
  
  
  class UserProfile {
  
  private String name;
  private String company;
  private SecurityPrincipa principal
  
  }
  </code></pre>
  
  <p>I want to get the sorted results of 'UserProfile' objects and it works fine for simple properties.Like</p>
  
  <pre><code>DetachedCriteria criteria=DetachedCriteria.forClass(UserProfile.class);     
  
  criteria.addOrder(Order.asc("name");
  </code></pre>
  
  <p>But when I try to access properties of inner bean (SecurityPrincipal instance) like </p>
  
  <pre><code>criteria.addOrder(Order.asc("principal.status");
  </code></pre>
  
  <p>Hibernate gives the error:</p>
  
  <blockquote>
    <p>Caused by:
    org.hibernate.QueryException: could
    not resolve property:
    securityPrincipal.status of:
    com.bigg.ibmd.usermanagement.model.UserProfile
      at
    org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:44)
      at
    org.hibernate.persister.entity.AbstractPropertyMapping.toColumns(AbstractPropertyMapping.java:59)
      at
    org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:31)</p>
  </blockquote>
  
  <p>How can I sort my results by properties-of-a-property?</p>
  
  <p>Thanks </p>