title: How can I cast a DataTable, to a List or ArrayList of another type of object
body: <p>I have a <code>DataTable</code> object which I need to cast to <code>List&lt;ScParametrics&gt;</code> and save the list to a database using Hibernate. </p>
  
  <p>The warning is <code>DataTable cannot be cast to java.util.List</code></p>
  
  <pre><code>public static addParamDataTable(DataTable listDataTable) {
      Session session = HibernateUtil.getSessionFactory();
      Transaction tx = session.beginTransaction();
  
      List&lt;ScParametrics&gt; list = (List) listDataTable;
      for (Iterator&lt;ScParametrics&gt; it = list.iterator(); it.hasNext();) {
          ScParametrics scParametrics = it.next();
          session.saveOrUpdate(scParametrics);
      }
  }
  </code></pre>