Help!

I am at a loss to figure out how to get past this one. The same code works perfectly fine when I test it against a MySQL database. I tried using the line containing the DB2Adapter statement but it made no difference.

I am running the following code:

sqlQuery = "Select * from SurveyResultDetails where survey_id = " + surveyID + " and question in " + "(Select question from SurveyQuestions, SurveyQuestionTypes where SurveyQuestionTypes.id = 8 and SurveyQuestions.question_type_id = 8) " +
     "order by result,survey_dts";

        ObjectContext context = BaseContext.getThreadObjectContext();
SQLTemplate select = new SQLTemplate(SurveyResultDetails.class, sqlQuery);
//        select.setTemplate(DB2Adapter.class.getName(), sqlQuery);

        List list = context.performQuery(select);

        for (Iterator it = list.iterator(); it.hasNext();) {
            SurveyResultDetails item = (SurveyResultDetails)it.next();
System.out.println("SurveyResultDetails item=" + item);
            result.add(item);
        }

The result of this is the following on DB2 V7:

2011-05-12 10:52:53,149 [http-8080-2] INFO org.apache.cayenne.access.QueryLogge r - Select * from SurveyResultDetails where survey_id = 1 and question in (Selec t question from SurveyQuestions, SurveyQuestionTypes where SurveyQuestionTypes.i
d = 5 and SurveyQuestions.question_type_id = 5) order by result, survey_dts
2011-05-12 10:52:53,189 [http-8080-2] INFO org.apache.cayenne.access.QueryLogge
r - === returned 10 rows. - took 40 ms.
2011-05-12 10:52:53,189 [http-8080-2] INFO org.apache.cayenne.access.QueryLogge
r - +++ transaction committed.
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null
SurveyResultDetails item=null

Here is the result on a MySQL data query (different data)

2011-05-12 10:42:58,200 [http-8084-2] INFO org.apache.cayenne.access.QueryLogger - Select * from SurveyResultDetails where survey_id = 1 and question in (Select question from SurveyQuestions, SurveyQuestionTypes where SurveyQuestionTypes.id = 5 and SurveyQuestions.question_type_id = 5) order by result, survey_dts 2011-05-12 10:42:58,208 [http-8084-2] INFO org.apache.cayenne.access.QueryLogger - === returned 3 rows. - took 8 ms. 2011-05-12 10:42:58,208 [http-8084-2] INFO org.apache.cayenne.access.QueryLogger - +++ transaction committed. SurveyResultDetails item={<ObjectId:SurveyResultDetails, id=50>; committed; [id=>50; result=>0; callerId=>5001110410145147; recMsg=>101453001; surveyDts=>Sun Apr 10 14:53:17 EDT 2011; question=>12; surveyId=>1; lang=>EN; note=>]} SurveyResultDetails item={<ObjectId:SurveyResultDetails, id=60>; committed; [id=>60; result=>0; callerId=>5001110410151543; recMsg=>101517001; surveyDts=>Sun Apr 10 15:17:11 EDT 2011; question=>12; surveyId=>1; lang=>EN; note=>]} SurveyResultDetails item={<ObjectId:SurveyResultDetails, id=88>; committed; [id=>88; result=>0; callerId=>5001110410161501; recMsg=>101616001; surveyDts=>Sun Apr 10 16:16:46 EDT 2011; question=>12; surveyId=>1; lang=>EN; note=>]}


HELP!

Andrew


Reply via email to