title: How to get the result as List<Class> in hibernate
body: <p>I'm working with hibernate(4) and did the following configuration.</p>
  
  <pre><code>&lt;bean id="sessionFactory"
          class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
          &lt;property name="annotatedClasses"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.myproj.model.Employee&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"
          class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="empdao" class="com.myproj.dao.EmpDao"&gt;
      &lt;qualifier value="q1"&gt;&lt;/qualifier&gt;
      &lt;property name="sessionFactory" ref="sessionFactory"&gt;&lt;/property&gt;
  </code></pre>
  
  <p>While implementing the basic query (selecting all the data from the DB) I'm getting the result as list of object but I want that result as List of custom class (in my case Employee). Below is the code snippet within the DAO file(empDao) for the same.</p>
  
  <pre><code>List&lt;Employee&gt; list = new ArrayList&lt;Employee&gt;();
  Session s = sessionFactory.openSession();
  
  
  try {
  s.beginTransaction();
  
  list= s.createQuery("from Employee").list();
  s.getTransaction().commit();
  
  } catch (Exception e) {
  System.out.println(e);
  }
  return list;
  </code></pre>
  
  <p>Here I'm getting the list as object array.. Help me to get the same as list of Employee class.</p>
  
  <p>Any kind of help is appreciated.</p>