如何在GAE上使用jpa上的数据存储区游标 [英] How to use datastore cursors with jpa on GAE
本文介绍了如何在GAE上使用jpa上的数据存储区游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何机构都知道如何在JPA中使用Datastore Cursors?
Any body know how to use Datastore Cursors with JPA?
推荐答案
=http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Query_Cursors =nofollow noreferrer> JDO示例):
Can you try this (adapted from the JDO sample):
List<Employee> results = (List<Employee>) query.execute();
// Use the first 20 results...
Cursor cursor = JPACursorHelper.getCursor(results);
String cursorString = cursor.toWebSafeString();
// Store the cursorString...
// ...
// Query query = the same query that produced the cursor
// String cursorString = the string from storage
Cursor cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
query.setFirstResult(0);
query.setMaxResults(20);
List<Employee> results = (List<Employee>) query.execute();
// Use the next 20 results...
这篇关于如何在GAE上使用jpa上的数据存储区游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文