Java StoredProcedure with SqlReturnResultSet not working

我们两清 提交于 2019-12-25 05:06:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!