Beispiel #1
0
  private ResultSet handleMultipleResults(
      PreparedStatement ps,
      StatementScope statementScope,
      int skipResults,
      int maxResults,
      RowHandlerCallback callback)
      throws SQLException {
    ResultSet rs;
    rs = getFirstResultSet(statementScope, ps);
    if (rs != null) {
      handleResults(statementScope, rs, skipResults, maxResults, callback);
    }

    // Multiple ResultSet handling
    if (callback.getRowHandler() instanceof DefaultRowHandler) {
      MappedStatement statement = statementScope.getStatement();
      DefaultRowHandler defaultRowHandler = ((DefaultRowHandler) callback.getRowHandler());
      if (statement.hasMultipleResultMaps()) {
        List multipleResults = new ArrayList();
        multipleResults.add(defaultRowHandler.getList());
        ResultMap[] resultMaps = statement.getAdditionalResultMaps();
        int i = 0;
        while (moveToNextResultsSafely(statementScope, ps)) {
          if (i >= resultMaps.length) break;
          ResultMap rm = resultMaps[i];
          statementScope.setResultMap(rm);
          rs = ps.getResultSet();
          DefaultRowHandler rh = new DefaultRowHandler();
          handleResults(
              statementScope, rs, skipResults, maxResults, new RowHandlerCallback(rm, null, rh));
          multipleResults.add(rh.getList());
          i++;
        }
        defaultRowHandler.setList(multipleResults);
        statementScope.setResultMap(statement.getResultMap());
      } else {
        while (moveToNextResultsSafely(statementScope, ps)) ;
      }
    }
    // End additional ResultSet handling
    return rs;
  }
Beispiel #2
0
 private static void setStatementTimeout(MappedStatement mappedStatement, Statement statement)
     throws SQLException {
   if (mappedStatement.getTimeout() != null) {
     statement.setQueryTimeout(mappedStatement.getTimeout().intValue());
   }
 }