0

if any one help me why i am geting following this exception here

List<abc> listQues=null;
for(int i=0;i<surveyIds.size();)
        {


            List<abc> listQue = (ArrayList<abc>) getHibernateTemplate().find("from abc as q where q.surveyId=" + surveyIds.get(0) + " order by q.pageNo asc, q.sortOrder asc");
            listQues.add((abc) listQue);


            i++;
        }

i am geting following Exception Here

java.lang.ClassCastException: java.util.ArrayList cannot be cast to com.inrev.crm.bean.IRSurveyQuestions

Please help me

Thanks

6
  • 1
    Pretty simple it seems that you are getting com.inrev.crm.bean.IRSurveyQuestions type of objects but trying to cast the same to ArrayList<abc> which is an error. Commented Jan 15, 2016 at 8:37
  • Does not look like that. Bean class is IRSurveyQuestions. It should have been a list of abc type. Commented Jan 15, 2016 at 8:45
  • i have changed bean name Commented Jan 15, 2016 at 8:46
  • What is the return type of getHibernateTemplate().find()? Commented Jan 15, 2016 at 8:49
  • what change you have done. I don't see. Commented Jan 15, 2016 at 8:49

1 Answer 1

1
listQues.add((abc) listQue); --???

How can you cast List<abc> to abc?? Change

List<abc> listQues=null; 

to

List<List<abc>> listQues=null;

and then on the line where you are adding questions list

listQues.add(listQue);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.