本文整理汇总了Java中com.google.appengine.api.datastore.PreparedQuery.asIterator方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedQuery.asIterator方法的具体用法?Java PreparedQuery.asIterator怎么用?Java PreparedQuery.asIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.datastore.PreparedQuery
的用法示例。
在下文中一共展示了PreparedQuery.asIterator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllTempData
import com.google.appengine.api.datastore.PreparedQuery; //导入方法依赖的package包/类
private static <T extends TempData> List<T> getAllTempData(Class<T> type, boolean unreadOnly) {
try {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
String kind = getKind(type);
Query query = new Query(kind);
if (unreadOnly) {
query.setFilter(new Query.FilterPredicate(TEMP_DATA_READ_PROPERTY, Query.FilterOperator.EQUAL, false));
} else {
query.addSort("timestamp", Query.SortDirection.ASCENDING);
}
PreparedQuery pq = ds.prepare(query);
Iterator<Entity> iter = pq.asIterator();
List<T> result = new ArrayList<>();
while (iter.hasNext()) {
Entity entity = iter.next();
T data = readTempData(type, entity, ds);
result.add(data);
}
return result;
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例2: getLastTempData
import com.google.appengine.api.datastore.PreparedQuery; //导入方法依赖的package包/类
public static <T extends TempData> T getLastTempData(Class<T> type) {
try {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
String kind = getKind(type);
PreparedQuery pq = ds.prepare(new Query(kind).addSort("timestamp", Query.SortDirection.DESCENDING));
Iterator<Entity> iter = pq.asIterator();
if (iter.hasNext()) {
Entity entity = iter.next();
return readTempData(type, entity, ds);
} else {
return null;
}
} catch (Exception e) {
throw new IllegalStateException(e);
}
}
示例3: assertIAEWhenAccessingIterator
import com.google.appengine.api.datastore.PreparedQuery; //导入方法依赖的package包/类
private void assertIAEWhenAccessingIterator(PreparedQuery preparedQuery) {
Iterator<Entity> iterator = preparedQuery.asIterator();
try {
iterator.hasNext();
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// pass
}
}