本文整理汇总了Java中com.google.appengine.api.datastore.Query.addProjection方法的典型用法代码示例。如果您正苦于以下问题:Java Query.addProjection方法的具体用法?Java Query.addProjection怎么用?Java Query.addProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.appengine.api.datastore.Query
的用法示例。
在下文中一共展示了Query.addProjection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: projectionQuery_grouping_filtersDuplicates
import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
@Test
public void projectionQuery_grouping_filtersDuplicates() {
putTestData("some duplicate", 0L);
putTestData("some duplicate", 0L);
putTestData("too big", 1L);
// [START grouping]
Query q = new Query("TestKind");
q.addProjection(new PropertyProjection("A", String.class));
q.addProjection(new PropertyProjection("B", Long.class));
q.setDistinct(true);
q.setFilter(Query.FilterOperator.LESS_THAN.of("B", 1L));
q.addSort("B", Query.SortDirection.DESCENDING);
q.addSort("A");
// [END grouping]
List<Entity> entities =
datastore.prepare(q).asList(FetchOptions.Builder.withLimit(5));
assertThat(entities).hasSize(1);
Entity entity = entities.get(0);
assertThat((String) entity.getProperty("A")).named("entity.A").isEqualTo("some duplicate");
assertThat((long) entity.getProperty("B")).named("entity.B").isEqualTo(0L);
}
示例2: projectionQuery_grouping_filtersDuplicates
import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
@Test
public void projectionQuery_grouping_filtersDuplicates() {
putTestData("some duplicate", 0L);
putTestData("some duplicate", 0L);
putTestData("too big", 1L);
// [START grouping]
Query q = new Query("TestKind");
q.addProjection(new PropertyProjection("A", String.class));
q.addProjection(new PropertyProjection("B", Long.class));
q.setDistinct(true);
q.setFilter(Query.FilterOperator.LESS_THAN.of("B", 1L));
q.addSort("B", Query.SortDirection.DESCENDING);
q.addSort("A");
// [END grouping]
List<Entity> entities = datastore.prepare(q).asList(FetchOptions.Builder.withLimit(5));
assertThat(entities).hasSize(1);
Entity entity = entities.get(0);
assertThat((String) entity.getProperty("A")).named("entity.A").isEqualTo("some duplicate");
assertThat((long) entity.getProperty("B")).named("entity.B").isEqualTo(0L);
}
示例3: timeZonesArray
import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
public static ArrayList<TimeZone> timeZonesArray() {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Query q = new Query(TimeZone.DatastoreProperties.KIND.getName());
q.addProjection(new PropertyProjection(TimeZone.DatastoreProperties.TIME_ZONE_ID.getName(), String.class));
PreparedQuery pq = datastore.prepare(q);
ArrayList<TimeZone> timeZones = new ArrayList<TimeZone>();
for(Entity result : pq.asIterable())
timeZones.add(new TimeZone(result));
return timeZones;
}
示例4: addGuestbookProjections
import com.google.appengine.api.datastore.Query; //导入方法依赖的package包/类
private void addGuestbookProjections(Query query) {
query.addProjection(new PropertyProjection("content", String.class));
query.addProjection(new PropertyProjection("date", Date.class));
}