问题
I have this SP in my Dao class:
private class ScoreStoredProcedure extends StoredProcedure {
private static final String SPROC_NAME = "loadUserScore";
public ScoreStoredProcedure(DataSource datasource) {
super(datasource, SPROC_NAME);
declareParameter(new SqlReturnResultSet("score", mScoreMapper));
declareParameter(new SqlParameter("vusername", Types.VARCHAR));
declareParameter(new SqlParameter("vuuid", Types.VARCHAR));
declareParameter(new SqlParameter("vlimit", Types.INTEGER));
compile();
}
@SuppressWarnings("unchecked")
public List<Score> execute(String pUsername, String pUUID, int pLimit){
Map<String,Object> lAllScore = super.execute(pUsername, pUUID, pLimit);
return ((List<Score>) lAllScore.get("score"));
}
}
Everything runs fine but I have problems with the mapping of the result list. I have this line in the logs:
INFO: Added default SqlReturnResultSet parameter named #result-set-2
but why the ResultSet is mapped on the key #result-set-2
?
Here I declared it as declareParameter(new SqlReturnResultSet("score", mScoreMapper));
Whats the problem? The RowMapper is correct created...
回答1:
Your stored procedure is generating more than one result set. Spring assigns the result sets that you haven't declared automatic names like the one you're seeing. See the description of this behaviour here: https://jira.springsource.org/browse/SPR-593?actionOrder=desc and discussion of how to handle multiple result sets at http://forum.spring.io/forum/spring-projects/data/27532-jdbctemplate-missing-some-functionality
来源:https://stackoverflow.com/questions/19349688/java-storedprocedure-with-sqlreturnresultset-not-working