本文整理了Java中org.jdbi.v3.core.statement.Query.setMaxRows
方法的一些代码示例,展示了Query.setMaxRows
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setMaxRows
方法的具体详情如下:
包路径:org.jdbi.v3.core.statement.Query
类名称:Query
方法名:setMaxRows
[英]Specify the maximum number of rows the query is to return. This uses the underlying JDBC Statement#setMaxRows(int)}.
[中]指定查询要返回的最大行数。它使用底层JDBC语句#setMaxRows(int)}。
代码示例来源:origin: jdbi/jdbi
@Override
public SqlStatementCustomizer createForMethod(Annotation annotation, Class<?> sqlObjectType, Method method) {
final int maxRows = ((MaxRows) annotation).value();
if (maxRows == DEFAULT_MAX_ROWS) {
throw new IllegalArgumentException(String.format(
"no value given for @%s on %s:%s",
MaxRows.class.getSimpleName(),
sqlObjectType.getName(),
method.getName())
);
}
if (maxRows <= 0) {
throw new IllegalArgumentException(String.format(
"@%s value given on %s:%s is %s, which is negative or 0. This makes no sense.",
MaxRows.class.getSimpleName(),
sqlObjectType.getName(),
method.getName(),
maxRows)
);
}
return stmt -> ((Query) stmt).setMaxRows(maxRows);
}
代码示例来源:origin: jdbi/jdbi
((Query) stmt).setMaxRows(maxRows);
};
代码示例来源:origin: jdbi/jdbi
@Test
public void testStatementCustomizersPersistAfterMap() {
h.execute("insert into something (id, name) values (?, ?)", 1, "hello");
h.execute("insert into something (id, name) values (?, ?)", 2, "world");
List<Something> rs = h.createQuery("select id, name from something")
.setMaxRows(1)
.mapToBean(Something.class)
.list();
assertThat(rs).hasSize(1);
}
内容来源于网络,如有侵权,请联系作者删除!