SimpleJdbcCall忽略JdbcTemplate fetch大小 [英] SimpleJdbcCall ignoring JdbcTemplate fetch size

查看:2039
本文介绍了SimpleJdbcCall忽略JdbcTemplate fetch大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们通过Spring SimpleJdbcCall调用pl / sql存储过程,SimpleJdbcCall忽略JdbcTemplate上设置的fetchsize。尽管我们已将jdbctemplate fetchsize设置为200,但是rowmapper resultset fetch size设置为10.任何想法为什么会发生这种情况,以及如何修复它?

We are calling the pl/sql stored procedure through Spring SimpleJdbcCall, the fetchsize set on the JdbcTemplate is being ignored by SimpleJdbcCall. The rowmapper resultset fetch size is set to 10 even though we have set the jdbctemplate fetchsize to 200. Any idea why this happens and how to fix it?

已打印fetchsize

Have printed the fetchsize of resultset in the rowmapper in the below code snippet - Once it is 200 and other time it is 10 even though I use the same JdbcTemplate on both occassion.

这个直接执行的结果集在rowmapper中的下面的代码片段 - 一旦是200和其他时候它是10,即使我使用相同的JdbcTemplate在这两个情况。通过jdbctemplate在行映射中返回200的fetchsize

This direct execution through jdbctemplate returns fetchsize of 200 in the row mapper

    jdbcTemplate = new JdbcTemplate(ds);
    jdbcTemplate.setResultsMapCaseInsensitive(true);
    jdbcTemplate.setFetchSize(200);

    List temp = jdbcTemplate.query("select 1 from dual", new ParameterizedRowMapper() {
        public Object mapRow(ResultSet resultSet, int i) throws SQLException {
            System.out.println("Direct template : " + resultSet.getFetchSize());
            return new String(resultSet.getString(1));
        }
    });

通过SimpleJdbcCall的执行总是在rowmapper中返回fetchsize 10。

This execution through SimpleJdbcCall is always returning fetchsize of 10 in the rowmapper

jdbcCall = new SimpleJdbcCall(jdbcTemplate).withSchemaName(schemaName)
                .withCatalogName(catalogName).withProcedureName(functionName);
jdbcCall.returningResultSet((String) outItValues.next(), new        ParameterizedRowMapper<Map<String, Object>>() {
                public Map<String, Object> mapRow(ResultSet rs, int row) throws SQLException {
                   System.out.println("Through simplejdbccall " + rs.getFetchSize());
                    return extractRS(rs, row);
                }
            });
outputList = (List<Map<String, Object>>) jdbcCall.executeObject(List.class, inParam);


推荐答案

我不知道 getFetchSize()方法 ResultSet 可以被信任。 JdbcTemplate Statement 上调用 setFetchSize() JDBC驱动程序将使用它做正确的事情,包括将其传播到所有 ResultSet 对象。在这种情况下,似乎Oracle JDBC驱动程序不是。

I'm not sure how much the getFetchSize() method on ResultSet can be trusted. JdbcTemplate calls setFetchSize() on the Statement, and assumes the JDBC driver will do the right thing with it, including propagating it to all ResultSet objects. It seems that the Oracle JDBC driver isn't, in this case.

这两种方法的不同行为的原因是执行一个简单的 SELECT 通过 JdbcTemplate 是简单的JDBC,而 ResultSet c $ c> SimpleJdbcCall 作为调用的OUT参数获取。

The reason you get different behaviour from the two approaches is that executing a simple SELECT through JdbcTemplate is simple JDBC, whereas the ResultSet you get back from SimpleJdbcCall is obtained as an OUT parameter to the call. The latter is more complex, and it seems the information is being lost.

作为解决方法,你尝试调用 ResultSet.setFetchSize()

As a workaround, have you tried calling ResultSet.setFetchSize() yourself? It might not work, but it's worth a go. You could also submit a issue to http://jira.springsource.org/ to see if they think that Spring's JDBC layer could address it transparently.

这篇关于SimpleJdbcCall忽略JdbcTemplate fetch大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆