Open GoogleCodeExporter opened 8 years ago
All tests for "JPACursorHelper" are clearly shown in public SVN at
http://code.google.com/p/datanucleus-appengine/source/browse/trunk/tests/com/goo
gle/appengine/datanucleus/query/JPQLCursorTest.java
They demonstrate all supported usages, and pass with every release (1.x, 2.0,
2.1). I'd suggest you inspect them and identify why yours is different, and/or
contribuet a patch to SVN trunk to add on a further test, and preferably a
patch to add that capability too
Original comment by googleco...@yahoo.co.uk
on 8 Jul 2012 at 9:47
Original comment by googleco...@yahoo.co.uk
on 15 Jul 2012 at 11:37
the null cursor occurs when doing a key only query.
i have a test case that shows issue.
test case attached.
i havent got a fix for it yet.
class JPQLCursorTest
--------------------------
public void testGetCursor_KeyOnlyList() {
Entity e1 = Book.newBookEntity("auth", "34", "yar");
Entity e2 = Book.newBookEntity("auth", "34", "yar");
Entity e3 = Book.newBookEntity("auth", "34", "yar");
ds.put(Arrays.asList(e1, e2, e3));
beginTxn();
Query q = em.createQuery("select id from " + Book.class.getName() + " b");
q.setMaxResults(1);
List<String> books = (List<String>) q.getResultList();
assertEquals(1, books.size());
assertEquals(e1.getKey(), KeyFactory.stringToKey(books.get(0)));
Cursor c = JPACursorHelper.getCursor(books);
assertNotNull(c);
q.setHint(JPACursorHelper.CURSOR_HINT, c);
books = (List<String>) q.getResultList();
assertEquals(1, books.size());
assertEquals(e2.getKey(), KeyFactory.stringToKey(books.get(0)));
assertNotNull(JPACursorHelper.getCursor(books));
q.setHint(JPACursorHelper.CURSOR_HINT, c.toWebSafeString());
books = (List<String>) q.getResultList();
assertEquals(1, books.size());
assertEquals(e2.getKey(), KeyFactory.stringToKey(books.get(0)));
c = JPACursorHelper.getCursor(books);
assertNotNull(c);
q.setHint(JPACursorHelper.CURSOR_HINT, c);
books = (List<String>) q.getResultList();
assertEquals(1, books.size());
assertEquals(e3.getKey(), KeyFactory.stringToKey(books.get(0)));
assertNotNull(JPACursorHelper.getCursor(books));
q.setHint(JPACursorHelper.CURSOR_HINT, c.toWebSafeString());
books = (List<String>) q.getResultList();
assertEquals(1, books.size());
assertEquals(e3.getKey(), KeyFactory.stringToKey(books.get(0)));
assertNotNull(JPACursorHelper.getCursor(books));
commitTxn();
}
Original comment by lu...@miiingle.com
on 19 Jul 2012 at 12:03
Hi, I have the same problem, with the generated code by Google eclipse plugin
the Cursor is NULL, this is the generated code, this always return null
APP Engine 1.9.3
Eclipse Kepler Standard.
Best Regards
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listPedido")
public CollectionResponse<Pedido> listPedido(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {
EntityManager mgr = null;
Cursor cursor = null;
List<Pedido> execute = null;
try {
mgr = getEntityManager();
Query query = mgr.createQuery("select from Pedido as Pedido");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<Pedido>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (Pedido obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<Pedido> builder().setItems(execute)
.setNextPageToken(cursorString).build();
}
Original comment by Ramses.B...@gmail.com
on 12 Aug 2014 at 6:50
Original issue reported on code.google.com by
lu...@miiingle.com
on 27 Jun 2012 at 1:05