title: Can't cast the result of query to entity
body: <p>everyone. I'm new to Hibernate. And I'm making desktop application. I have 2 tables: Worker and Ceh (i.e. Department). Relation between them: many-to-one, i.e. 1 Ceh may contain many workers.
  I run hql query with inner join to show info about all workers including name of the department and want to show the results in JTable. </p>
  
  <p>The hql query: </p>
  
  <p><code>private static String query_All_Workers="select W.fio, W.nomer, W.salary, C.name  from Worker W Inner Join W.ceh C;</code></p>
  
  <p>The method that runs query:</p>
  
  <pre><code>   try {
          Session session = HibernateUtil.getSessionFactory().openSession();
          session.beginTransaction();
          Query q = session.createQuery(hql);
          List resultList = q.list();
          displayResult(resultList);
          session.getTransaction().commit();
      } catch (HibernateException he) {
          he.printStackTrace();
      }
  </code></pre>
  
  <p>The method displayResult(List resultList):</p>
  
  <pre><code>Vector&lt;String&gt; tableHeaders = new Vector&lt;&gt;();
      tableHeaders.add("FIO"); 
      tableHeaders.add("Nomer");
      tableHeaders.add("Salary");
      tableHeaders.add("Ceh");
  
      Vector tableData = new Vector();
      for(Object o : resultList) {
          Worker worker = (Worker)o;
          Vector&lt;Object&gt; oneRow = new Vector&lt;Object&gt;();
          oneRow.add(worker.getFio());
          oneRow.add(worker.getNomer());
          oneRow.add(worker.getSalary());
          oneRow.add(worker.getCeh());
          tableData.add(oneRow);
      }
      resultTable.setModel(new DefaultTableModel(tableData, tableHeaders));
  </code></pre>
  
  <p>And the exception occurs like this:</p>
  
  <blockquote>
    <p>"java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to
    workers.entity.Worker"</p>
  </blockquote>
  
  <p>It happens because the list contains objects which are results of inner join query. So I don't know how  I can correctly cast the object to Worker entity in order to use its getters.</p>