title: Advice for code simplification for joint table
body: <p>I need advice for my code simplification. I am using Struts 2, Spring, and Hibernate as framework.</p>
  <p><strong>File DAO:</strong></p>
  <pre><code>public List&lt;Model&gt; getData() throws HibernateException {
  
      List&lt;Model&gt; list = new ArrayList&lt;Model&gt;();
      List&lt;Object[]&gt; res = new ArrayList&lt;Object[]&gt;();
      String query = &quot;SELECT table1.*, table2.* FROM table1, table2 WHERE table1.bridge_id = table2.bridge_id&quot;;
      res = this.sessionFactory.getCurrentSession()
              .createSQLQuery(query)
              .list();
  
      for (Object[] row : res) {
          Model model = new Model();
          model.setName((String) row[1]);
          model.setDate((Date) row[2]);
  
          list.add(model);
      }
      return list;
  }
  </code></pre>
  <p>I try using</p>
  <pre><code>while(res.next()){ ... }
  </code></pre>
  <p>but <code>next()</code> is not function in my project, like I am using <code>size()</code> to count size of the list rather than <code>length</code> of array.</p>
  <p>for some reason I dont like to define function value in loop using <code>row[0]</code>, what I want is to define the value as <code>row[&quot;name&quot;]</code>.</p>