如何使用数据存储光标与GAE JPA(How to use datastore cursors wi

2019-10-20 12:18发布

任何机构知道如何使用数据存储游标与JPA?

Answer 1:

你可以试试这个(改编自JDO样本 ):

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...


文章来源: How to use datastore cursors with jpa on GAE