/** * 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)); }
@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 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)); }