title: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to className
body: <p><strong>Code:</strong></p>
  
  <pre><code>public void getDetails() {
  try {
  Session session = sessionFactory.openSession();
  Transaction transaction = session.beginTransaction();
  String hql = "select c.mobile, c.password FROM CrbtSubMasterDemo c where rownum&lt;20";
  Query query = session.createQuery(hql);
  List&lt;CrbtSubMasterDemo&gt; itr = query.list();
  session.getTransaction().commit();
  for (CrbtSubMasterDemo pojo : itr) {//excepion line
  System.out.println("[" + pojo.getMobile() + "]");
  }
  } catch (Exception e) {
  e.printStackTrace();
  }
  }
  </code></pre>
  
  <p><strong>CrbtSubMasterDemo</strong> is pojo mapped with the db.
  When I try to run it, it gives following Exception:</p>
  
  <pre><code>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.telemune.demoPojo.CrbtSubMasterDemo
  at com.telemune.demoHibernate.QueryTester.getDetails(QueryTester.java:57)
  at com.telemune.demoHibernate.QueryTester.main(QueryTester.java:23)
  </code></pre>
  
  <p>The question is query.list() is returning the list of objects of pojo class. Then why is this Exception. I am new to Hibernate, sorry if its a silly question.</p>