SimpleJdbcCall ignores JdbcTemplate sample size

We call the pl / sql stored procedure through Spring SimpleJdbcCall, the fetchsize set on the JdbcTemplate is ignored by SimpleJdbcCall. The sample size of the rowmapper template results is 10, although we set the fetchsize for jdbctemplate to 200. Any idea why this is happening and how to fix it?

Printed fetchsize from the result set into a line string in the code snippet below. When it's 200, and at another time it's 10, although I use the same JdbcTemplate in both cases.

This direct execution via jdbctemplate returns fetchsize of 200 in mapperper lines

    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));
        }
    });

This execution via SimpleJdbcCall always returns fetchsize from 10 in 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);
+3
3

, getFetchSize() ResultSet. JdbcTemplate setFetchSize() Statement , JDBC , ResultSet. , JDBC Oracle .

, , , SELECT JdbcTemplate - JDBC, ResultSet, SimpleJdbcCall, OUT , , , .

, ResultSet.setFetchSize() ? , , . http://jira.springsource.org/, , , Spring JDBC .

+4

, Oracle, :

SELECT * FROM (SELECT ROWNUM as id, demo.* FROM DEMO_TABLE demo)
WHERE id >= startRowNumber AND id <= stopRowNumber; 

- Oracle, JPA JDBC:

Query selectQuery = entityManager.createQuery(queryString);
selectQuery.setMaxResults(maxNumberOfElements);
selectQuery.setFirstResult(startRowNumber);
List demoList = entityManager.getResultList(queryString);
+2

Not a direct answer, but a useful thing, I think. When you create spring class objects manually, most people tend to forget to call the afterPropertiesSet () method (which spring calls to do any initialization).

I checked jdbcTemplate.afterPropertiesSet (), it only seems to be installed by the exception translator and the data source.

0
source

Source: https://habr.com/ru/post/1736067/


All Articles