开发者

How to use datastore cursors with jpa on GAE

开发者 https://www.devze.com 2022-12-23 20:59 出处:网络
Any body know how to use Datastore Cursors with JP开发者_C百科A?Can you try this (adapted from the JDO sample):

Any body know how to use Datastore Cursors with JP开发者_C百科A?


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

精彩评论

暂无评论...
验证码 换一张
取 消