【发布时间】:2015-01-11 12:24:16
【问题描述】:
我有一个关于 Datastore 如何生成游标的问题,我在下面有这段代码,即使结果列表为空,仍然会返回游标:
if(asList){
if(startCursor != null && startCursor.getWebSafeString() != null){
fetchOptions.startCursor(Cursor.fromWebSafeString(startCursor.getWebSafeString()));
res = pq.asQueryResultList(fetchOptions);
} else if(startCursor != null && startCursor.getWebSafeString() == null) {
res = pq.asQueryResultList(fetchOptions);
} else {
res = pq.asList(fetchOptions);
}
} else {
if(startCursor != null && startCursor.getWebSafeString() != null){
fetchOptions.startCursor(Cursor.fromWebSafeString(startCursor.getWebSafeString()));
res = pq.asQueryResultIterable(fetchOptions);
} else if(startCursor != null && startCursor.getWebSafeString() == null){
res = pq.asQueryResultIterable(fetchOptions);
} else {
res = pq.asIterator(fetchOptions);
}
}
return res;
res这里是查询结果:
String newCursor = res.getCursor().toWebSafeString();
即使res列表为空返回游标,是否正常?或者这有什么问题?
【问题讨论】:
标签: java google-app-engine google-cloud-datastore