Hi
I want to execute select query on my table using hibernate,
it works correctly and I get Iterator from query,when I cast Object of Iterator to my class(named Person),
it show this exception:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.domain.Person
someone help me please.
here is my code of my query:
Code:
public LinkedList select(){
LinkedList list= new LinkedList();
org.hibernate.Transaction tx;
sessionFactory= (SessionFactory) HibernateUtil.getSessionFactory();
session =sessionFactory.openSession();
tx= (org.hibernate.Transaction) session.beginTransaction();
try{
Query query= session.createQuery("select person.code1,person.name,person.debtorCurrency from " + Person.class.getName()+ " person");
Collection col= (Collection) query.list();
list.addAll(col);
tx.commit();
}catch(Exception e){
tx.rollback();
e.printStackTrace();
}finally{
session.close();
return list;
}
}