gpt4 book ai didi

java - 如何限制 CriteriaBuilder 查询中的记录数?

转载 作者:行者123 更新时间:2023-12-01 06:01:12 26 4
gpt4 key购买 nike

我想限制 CriteriaBuilder 中的数据数量,因此我的代码如下所示。

typeQuery.setFirstResult(0);
typeQuery.setMaxResults(10);
typeQuery.getResultList();

but instead of limiting on Database it is fetching whole data and then fetch limit data from session.

so my question is how can i limit rows directly from database?



最佳答案

试试这个

Integer firstItem = 0;
Integer numOfItems = 10;

return entityManager.createQuery(typeQuery).setFirstResult(firstItem).setMaxResults(numOfItems).getResultList();

执行查询时

关于java - 如何限制 CriteriaBuilder 查询中的记录数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58376276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com