Hi,
I've just come accross what seems to me, to be rather odd behaviour when using a RowMapperResultReader.
Basically, I'm accessing an oracle stored procedure that returns a cursor as one of it's out parameters. My code is as follows:
All works fine the first time round. When, however, I try to get another result (with the same parameters), with the same PositionHistoryFindByPk object, it fails at the uniqueResult function, throwing a IncorrectResultSizeDataAccessException. It appears that the result size is equal to the number of calls I have made to getValueObject(pk)HTML Code:public class PositionHistoryFindByPK extends StoredProcedure { private static final String SQL = "lv_sys.tracklog_interface_pkg.find_by_primary_key"; private RowMapperResultReader resultReader = null; protected PositionHistoryFindByPK(DataSource dataSource) { RowMapper rowMapper = new PositionHistoryRowMapper(); this.resultReader = new RowMapperResultReader(rowMapper, 1); setDataSource(dataSource); setSql(SQL); declareParameter(new SqlParameter("i_pk", Types.INTEGER)); declareParameter(new SqlOutParameter("o_result", OracleTypes.CURSOR, this.resultReader)); } public PositionHistoryVO getValueObject(Integer pk) { Map params = new HashMap(1); params.put("i_pk", pk); execute(params); return (PositionHistoryVO) DataAccessUtils.uniqueResult(this.resultReader.getResults()); } }
If, however, I change the getValueObject code to readthen everything works fine - the clearing of the results list between calls cures the problem.HTML Code:synchronized (this.resultReader){ this.resultReader.getResults().clear(); Map params = new HashMap(1); params.put("i_pk", pk); execute(params); return (PositionHistoryVO) DataAccessUtils.uniqueResult(this.resultReader.getResults()); }
Questions:
1) Is this the desired behaviour of the RowMapperResultReader?
2) If so, please explain why
3) Am I abusing the RowMapperResultReader? If so, how should it be used?
TIA
John Grange![]()


Reply With Quote