jpa 2休眠限制(最大结果)到CriteriaQuery [英] jpa 2 hibernate limit (max results) to a CriteriaQuery

查看:178
本文介绍了jpa 2休眠限制(最大结果)到CriteriaQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个愚蠢的问题,但我无法在文档中找到答案:
如何使用JPA2设置CriteriaQuery的限制?

maybe it's a silly question but I cannot find the answer in the docs: How can set a limit to the CriteriaQuery using JPA2?

谢谢

推荐答案

CriteriaQuery不是可执行的Query。您需要首先使用 EntityManager.createQuery(criteriaQuery)创建一个TypedQuery。然后,您可以设置此最大结果并执行它。

A CriteriaQuery is not an executable Query. You need to create a TypedQuery first using EntityManager.createQuery(criteriaQuery). You can then set the max results of this and execute it.

这篇关于jpa 2休眠限制(最大结果)到CriteriaQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆