I'm developing my website in struts, hibernate and jsp. I had called a function which is in my DAO page from my action page like this:
private List<Order> salesDetails = new ArrayList();
salesDetails = doctorDao.getInstance().getDoctorSalesDetails(SessionObj.getId(),activityGraph);
and in my dao function I write the code like this
public List getDoctorSalesDetails(int id,int activityGraph){
List<Order> doctorSalesDetails=new ArrayList();
try{
SessionFactory sessionFactory =
(SessionFactory) ServletActionContext.getServletContext().getAttribute(HibernateListener.KEY_NAME);
Session Hibernatesession = sessionFactory.openSession();
Hibernatesession.beginTransaction();
doctorSalesDetails = Hibernatesession.createSQLQuery("SELECT total_amount,created_at FROM `order` WHERE created_at > DATE_SUB(curdate(),INTERVAL "+activityGraph+" DAY) AND doctor_id = "+id+" GROUP BY created_at").list();
Hibernatesession.getTransaction().commit();
}catch(Exception e){
e.printStackTrace();
}
return doctorSalesDetails;
}
The query result is successfully working here. The problem is when I access the the return variable from my action page like this:
try{
for( Order o: salesDetails) {
System.out.println("Total amount="+o.getCreatedAt());
}
}catch(Exception e){
e.printStackTrace();
}
it causes following error :
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.myDrDirect.hbmobj.Order
at com.myDrDirect.doctor.action.DoctorDashBoardActivity.getDashBoardActivityDetails(DoctorDashBoardActivity.java:36)
What might be the issue?