title: hibernate how to retrieve a hierarchy object
body: <p>I have the following beans Task, ServerDetails and ApplicationDetails.
  I wish to retrieve all tasks, their server details and application details based on a specific application name.</p>
  
  <p>From the result i expect to be able to retrieve the data in a manner such as: 
  task.getServers().getApplicationDetails()</p>
  
  <p>In actuality, I get what seems to be flat data's representation as an Object[].</p>
  
  <p>Is there any way to do what i propose? </p>
  
  <p>Following is my code...</p>
  
  <pre><code>class Task {
      private String taskId;
      private Set&lt;ServerDetails&gt; servers;
  }
  
  class ServerDetails {
      private String id;
      private Set&lt;ApplicationDetails&gt; applications;
  }
  
  class ApplicationDetails {
     private String id;
  }
  </code></pre>
  
  <p>HQL:</p>
  
  <pre><code>StringBuilder hql = new StringBuilder(256);
  hql.append("FROM Task h, ServerDetails ser, ApplicationDetails app ");
  hql.append("WHERE h.executionDate &gt; "); 
  hql.append("to_date('");
  hql.append(DBDateFormatter.getInstance().formatDate(cal));
  hql.append("',  '");
  hql.append(DBDateFormatter.getInstance().getOracleDateFormat());
  hql.append("') and h.id = ser.task.id and ser.id = app.server and app.name = 'XXX'");
  hql.append(" order by h.executionDate desc");
  String hql = hql.toString();
  
  Query query = session.createQuery(hql);      
  results = (List&lt;Object[]&gt;) query.list();
  </code></pre>