1
questions=dao.getNamedQueryResultList("getUnansweredQuestionsByCategory", new Object[]{strUser});



    for(Question selectedResumes:questions) {
          //do something with the SelectedResumes object
        System.out.println("Unanswered::"+selectedResumes.getQuestion());
    }

================================================== ==================== -

following error is coming:

java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to com.sx.mcqs.model.Question at com.sx.mcqs.service.QuestionService.findRelatedQuestionsGame(QuestionService.java:142) at com.sx.mcqs.service.QuestionService$$FastClassByCGLIB$$cd78275c.invoke () at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191) at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689) at org.springframework.aop.framework .ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework。

4

1 に答える 1

3

上記のコードは、名前付きクエリが質問のリストを返すことを前提としていますが、オブジェクトの配列を返します。質問のリストを返すには、クエリは次のようになります。

select question from Question question ...

しかし、クエリはおそらく次のようになります

select question.foo, question.bar, ...

実行されたクエリを見ずに、より詳細な答えを出すのは難しいです。

于 2012-08-10T07:59:11.873 に答える