当前位置: 首页>>代码示例>>Java>>正文


Java Query.addProjection方法代码示例

本文整理汇总了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);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:24,代码来源:ProjectionTest.java

示例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);
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:23,代码来源:ProjectionTest.java

示例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;
}
 
开发者ID:kerafill1116,项目名称:apollo-datastore,代码行数:11,代码来源:JSTLFunctions.java

示例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));
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:5,代码来源:ProjectionServlet.java


注:本文中的com.google.appengine.api.datastore.Query.addProjection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。