/** * Specify the maximum number of rows the query is to return. This uses the underlying JDBC * {@link Statement#setMaxRows(int)}}. * * @param maxRows maximum number of rows to return * * @return modified query */ public Query setMaxRows(final int maxRows) { return addCustomizer(StatementCustomizers.maxRows(maxRows)); }
/** * Specify the fetch size for the query. This should cause the results to be * fetched from the underlying RDBMS in groups of rows equal to the number passed. * This is useful for doing chunked streaming of results when exhausting memory * could be a problem. * * @param fetchSize the number of rows to fetch in a bunch * * @return the modified query */ public Query setFetchSize(final int fetchSize) { return addCustomizer(StatementCustomizers.fetchSize(fetchSize)); }
/** * Specify the maximum field size in the result set. This uses the underlying JDBC * {@link Statement#setMaxFieldSize(int)} * * @param maxFields maximum field size * * @return modified query */ public Query setMaxFieldSize(final int maxFields) { return addCustomizer(StatementCustomizers.maxFieldSize(maxFields)); }
/** * Set the query timeout, in seconds, on the prepared statement * * @param seconds number of seconds before timing out * * @return the same Query instance */ public This setQueryTimeout(final int seconds) { return addCustomizer(StatementCustomizers.statementTimeout(seconds)); }
/** * Set the fetch direction. * @param value the direction to fetch * @return this * @see PreparedStatement#setFetchDirection(int) * @see java.sql.ResultSet#FETCH_FORWARD * @see java.sql.ResultSet#FETCH_REVERSE */ public This setFetchDirection(final int value) { addCustomizer(StatementCustomizers.fetchDirection(value)); return typedThis; }
/** * Set the query timeout, in seconds, on the prepared statement * * @param seconds number of seconds before timing out * * @return the same Query instance */ public This setQueryTimeout(final int seconds) { return addCustomizer(StatementCustomizers.statementTimeout(seconds)); }
@Test public void testGlobalStatementCustomizers() throws Exception { dbRule.getJdbi().addCustomizer(StatementCustomizers.maxRows(1)); handle = dbRule.openHandle(); handle.execute("insert into something (id, name) values (?, ?)", 1, "hello"); handle.execute("insert into something (id, name) values (?, ?)", 2, "world"); List<Something> rs = handle.createQuery("select id, name from something") .mapToBean(Something.class) .list(); assertThat(rs).hasSize(1); }
/** * Specify the maximum field size in the result set. This uses the underlying JDBC * {@link Statement#setMaxFieldSize(int)} * * @param maxFields maximum field size * * @return modified query */ public Query setMaxFieldSize(final int maxFields) { return addCustomizer(StatementCustomizers.maxFieldSize(maxFields)); }
/** * Specify the fetch size for the query. This should cause the results to be * fetched from the underlying RDBMS in groups of rows equal to the number passed. * This is useful for doing chunked streaming of results when exhausting memory * could be a problem. * * @param fetchSize the number of rows to fetch in a bunch * * @return the modified query */ public Query setFetchSize(final int fetchSize) { return addCustomizer(StatementCustomizers.fetchSize(fetchSize)); }
/** * Specify the maximum number of rows the query is to return. This uses the underlying JDBC * {@link Statement#setMaxRows(int)}}. * * @param maxRows maximum number of rows to return * * @return modified query */ public Query setMaxRows(final int maxRows) { return addCustomizer(StatementCustomizers.maxRows(maxRows)); }