title: Multiple Rows, wrapped in one object
body: <p>This is a follow up on my last question, building my dynamic questionnaire.</p>
  
  <p>So I have query that joins all the tables I need to dynamically create the page.</p>
  
  <p>Structure looks as follows(Cant upload picture, not enough rep)</p>
  
  <pre><code>Question    QuestionType        Possible answer 
  -------------------------------------------
  How far     Single Choice       Too Far 
  How far     Single Choice       Not too far 
  How long    Multiple Choice     Way long
  How long    Multiple Choice     Huh?
  How long    Multiple Choice     Dumb question   
  </code></pre>
  
  <p>The query returns a row for each possible answer, sometimes 2, other times 4. No restriction how many options a single question can have.</p>
  
  <p>In my project i have an XML structure that my application uses to build the page.</p>
  
  <pre><code>&lt;rowset&gt;
      &lt;row&gt;
          &lt;questionText&gt;This is a single choice question*&lt;/questionText&gt;
          &lt;questionType&gt;Single Choice&lt;/questionType&gt;
          &lt;possibleAnswerSet&gt;
              &lt;possibleAnswer&gt;Yes&lt;/possibleAnswer&gt;
              &lt;possibleAnswer&gt;No&lt;/possibleAnswer&gt;
              &lt;possibleAnswer&gt;Maybe&lt;/possibleAnswer&gt;
          &lt;/possibleAnswerSet&gt;
      &lt;/row&gt;
      &lt;row&gt;
          &lt;questionText&gt;This is a survey question&lt;/questionText&gt;
          &lt;questionType&gt;Survey&lt;/questionType&gt;
          &lt;possibleAnswerSet&gt;
              &lt;possibleAnswer&gt;&lt;/possibleAnswer&gt;
          &lt;/possibleAnswerSet&gt;
      &lt;/row&gt;
      &lt;row&gt;
          &lt;questionText&gt;This is a mutiple choice question*&lt;/questionText&gt;
          &lt;questionType&gt;Multiple Choice&lt;/questionType&gt;
          &lt;possibleAnswerSet&gt;
              &lt;possibleAnswer&gt;Apples&lt;/possibleAnswer&gt;
              &lt;possibleAnswer&gt;Bananas&lt;/possibleAnswer&gt;
              &lt;possibleAnswer&gt;Cranberries&lt;/possibleAnswer&gt;
              &lt;possibleAnswer&gt;Dragon fruit&lt;/possibleAnswer&gt;
          &lt;/possibleAnswerSet&gt;
      &lt;/row&gt;
  &lt;/rowset&gt;
  </code></pre>
  
  <p>This piece works perfect, with data hard coded in the XML, my page generates.
  So my question is, from resultSet that is returned from my query, i want to wrap all the associated answers in List or some other collection, so that i can populate the XML as described above.</p>
  
  <p>This is how Im currently setting, and It returns an object for each POSSIBLE_ANSWER, not each Question</p>
  
  <pre><code>try 
          {
              while (rset.next()) 
              {
                  ClientPojo clientObj = new ClientPojo();
  
                  questionOptions = rset.getInt("QUESTION_OPTIONS");
                  passPercentage = rset.getInt("CATEGORY_PASS_PERCENTAGE");
                  questionText = rset.getString("QUESTION_TEXT");
                  questionType = rset.getString("QUESTION_TYPE");
                  categoryName = rset.getString("CATEGORY_NAME");
                  possibleAnswerText = rset.getString("POSSIBLE_ANSWER_TEXT");
                  possibleAnswerCorrect = rset.getString("POSSIBLE_ANSWER_CORRECT");
                  questionId = rset.getInt("QUESTION_ID");
  
                  clientObj.setAssessmentAreaId(assessmentAreaId);
                  clientObj.setCategoryName(categoryName);
                  clientObj.setPassPercentage(passPercentage);
                  clientObj.setPossibleAnswerCorrect(possibleAnswerCorrect);
                  clientObj.setPossibleAnswerText(possibleAnswerText);
                  clientObj.setQuestionOptions(questionOptions);
                  clientObj.setQuestionText(questionText);
                  clientObj.setQuestionType(questionType);
                  clientObj.setQuestionId(questionId);
  
                  questionsList.add(clientObj);
              }
          }
  </code></pre>
  
  <p>Is what i want possible with the query im using, or do i need to change that.</p>
  
  <p>EDIT:
  Here's my query:</p>
  
  <pre><code>SELECT "CAQ_SCHEMA"."QUESTION".*, "CAQ_SCHEMA"."CATEGORY".*, "CAQ_SCHEMA"."CATEGORY_QUESTION_LINK".*, "CAQ_SCHEMA"."POSSIBLE_ANSWER".* , "CAQ_SCHEMA"."ASSESSMENT_AREA".* 
  FROM "CAQ_SCHEMA"."QUESTION" 
      JOIN "CAQ_SCHEMA"."CATEGORY_QUESTION_LINK" 
          ON "CAQ_SCHEMA"."CATEGORY_QUESTION_LINK".QUESTION_ID = "CAQ_SCHEMA"."QUESTION".QUESTION_ID
      JOIN "CAQ_SCHEMA"."POSSIBLE_ANSWER"
          ON "CAQ_SCHEMA"."POSSIBLE_ANSWER".QUESTION_ID = "CAQ_SCHEMA"."QUESTION".QUESTION_ID
      JOIN "CAQ_SCHEMA"."CATEGORY" 
          ON "CAQ_SCHEMA"."CATEGORY".CATEGORY_ID = "CAQ_SCHEMA"."CATEGORY_QUESTION_LINK".CATEGORY_ID
      JOIN "CAQ_SCHEMA"."ASSESSMENT_AREA"
          ON "CAQ_SCHEMA"."ASSESSMENT_AREA".ASSESSMENT_AREA_ID = "CAQ_SCHEMA"."CATEGORY".ASSESSMENT_AREA_ID
      WHERE "CAQ_SCHEMA"."ASSESSMENT_AREA".ASSESSMENT_AREA_ID = '1';
  </code></pre>
  
  <p>Thanks guys.</p>