问题描述
我的班上有这个SP:
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
但是为什么将ResultSet映射到键#result-set-2
上?在这里,我将其声明为declareParameter(new SqlReturnResultSet("score", mScoreMapper));
but why the ResultSet is mapped on the key #result-set-2
?Here I declared it as declareParameter(new SqlReturnResultSet("score", mScoreMapper));
出什么问题了? RowMapper已正确创建...
Whats the problem? The RowMapper is correct created...
推荐答案
您的存储过程正在生成多个结果集. Spring会为您分配尚未声明自动名称的结果集,就像您看到的那样.请在此处查看此行为的说明: https://jira.springsource.org/browse/SPR-593?actionOrder = desc 以及有关如何处理多个结果集的讨论,位于 http://forum.spring.io/forum/spring-projects/data/27532-jdbctemplate-missing-some-functionity
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
这篇关于带有SqlReturnResultSet的Java StoredProcedure不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!