@Override
 public void saveQuestionInSortedPosition(Question question) {
   Connection conn = null;
   PreparedStatement stat = null;
   ResultSet res = null;
   try {
     conn = this.getConnection();
     conn.setAutoCommit(false);
     stat = conn.prepareStatement(GET_QUESTION_GREATER_POS);
     stat.setInt(1, question.getSurveyId());
     res = stat.executeQuery();
     if (res.next()) {
       int lastPosition = res.getInt(1);
       question.setPos(++lastPosition);
     } else {
       question.setPos(0);
     }
     this.saveQuestion(conn, question);
     conn.commit();
   } catch (Throwable t) {
     this.executeRollback(conn);
     _logger.error("Error while saving a question in a sorted position", t);
     throw new RuntimeException("Error while saving a question in a sorted position", t);
   } finally {
     closeDaoResources(res, stat, conn);
   }
 }
 @Override
 public Question loadQuestion(int id) {
   Question question = null;
   Connection conn = null;
   PreparedStatement stat = null;
   ResultSet res = null;
   try {
     conn = this.getConnection();
     stat = conn.prepareStatement(GET_COMPLETE_QUESTION_BY_ID);
     stat.setInt(1, id);
     res = stat.executeQuery();
     while (res.next()) {
       if (null == question) {
         question = this.buildQuestionRecordFromResultSet(res, 1);
       }
       // get extra info: questions need the survey type
       int questionnaireValue = res.getInt(13);
       boolean questionnaire = questionnaireValue == 1 ? true : false;
       ApsProperties titles = new ApsProperties();
       titles.loadFromXml(res.getString(14));
       question.setExtraInfo(questionnaire, titles);
       Choice choice = this.buildChoiceRecordFromResultSet(res, 8);
       if (null == choice) continue;
       choice.setExtraInfo(
           question.getSurveyId(),
           question.isQuestionnaire(),
           question.getSurveyTitles(),
           question.getQuestions());
       if (null == question.getChoice(choice.getId())) {
         question.getChoices().add(choice);
       }
     }
   } catch (Throwable t) {
     _logger.error("Error while loading the question of ID {}", t);
     throw new RuntimeException("Error while loading a question", t);
   } finally {
     closeDaoResources(res, stat, conn);
   }
   return question;
 }