像Hibernate或JPA中的游标或记录集迭代器? [英] Something like cursor or recordset iterator in Hibernate or JPA?

查看:932
本文介绍了像Hibernate或JPA中的游标或记录集迭代器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在Hibernate中处理长查询结果吗?如果我想绘制有百万条记录的表,并允许用户在其上导航,该怎么办?

Are there any means to work with long query results in Hibernate? What if I want to draw table with million of records and allow user to navigate over it?

目标不是在此时将所有数据传输到客户端,当前位置。

The goal is not to transfer all data to client at the time and handle the current position.

推荐答案

您可以使用 FirstResult code> MaxResults 在查询对象中。

You can use simple mechanism of FirstResult and MaxResults in a Query object.

query.setFirstResult(5);
query.setMaxResults(5);

以上将从第五条记录中提取 5

Above will fetch 5 records from fifth record.

您可以使用 ScrollableResults ,但是对于较大的结果,它会比上面的慢一些。

You can use ScrollableResults but it will be slower compared to above one for large results.

这篇关于像Hibernate或JPA中的游标或记录集迭代器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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