[ https://issues.apache.org/jira/browse/IBATIS-537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634061#action_12634061 ]
Amol Jadhav commented on IBATIS-537: ------------------------------------ Have attached both the files involved... Clinton you can go ahead... > Multiple external RowHandler support > ------------------------------------ > > Key: IBATIS-537 > URL: https://issues.apache.org/jira/browse/IBATIS-537 > Project: iBatis for Java > Issue Type: Improvement > Components: SQL Maps > Affects Versions: 2.3.3 > Reporter: Amol Jadhav > Priority: Minor > Attachments: MultiRowHandler.java, SqlExecutor.java > > > We have MS-SQL store proc which returns mutiple result sets. The results > sets are big and it will not be a good idea to put them in ArraList. The > current iBatis version do not support multiple external RowHandler (external > means, provided by iBatis user). By defualt iBatis uses DefaultRowHandler to > process multiple resultsets, the current code which handles multiple > resultset is as below > Class: com.ibatis.sqlmap.engine.execution.SqlExecutor > in method private ResultSet handleMultipleResults(.... > // 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 > The fix which was put to solve this was as below, please let me know your > suggestions. > 1. A new interface as below > > package com.ibatis.sqlmap.client.event; > import com.ibatis.sqlmap.client.event.RowHandler; > public interface MultiRowHandler extends RowHandler{ > public MultiRowHandler getNextRowHandler(); > } > 2. Changes to com.ibatis.sqlmap.engine.execution.SqlExecutor > if (callback.getRowHandler() instanceof MultiRowHandler) { > MappedStatement statement = statementScope.getStatement(); > MultiRowHandler multipleRowHandler = > (MultiRowHandler)callback.getRowHandler(); > if (statement.hasMultipleResultMaps()) { > 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(); > RowHandler rh = multipleRowHandler.getNextRowHandler(); > RowHandlerCallback hdc = new RowHandlerCallback(rm, null, rh); > handleResults(statementScope, rs, skipResults, maxResults,hdc ); > multipleRowHandler = (MultiRowHandler)hdc.getRowHandler(); > i++; > } > statementScope.setResultMap(statement.getResultMap()); > } else { > while (moveToNextResultsSafely(statementScope, ps)) ; > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.