Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.PreparedQuery.asList()


        Query query = new Query("User");
       
        query.addSort("rating", SortDirection.DESCENDING);
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        PreparedQuery pq = ds.prepare(query);
        List<Entity> results = pq.asList(FetchOptions.Builder.withLimit(number).offset(offset));
        List<User> ret = new ArrayList<User>();
        for(Entity e: results)
        {
            ret.add(new User(e));
        }
View Full Code Here


  private List<Entity> runQuery(Query q, final int limit) {
    final PreparedQuery preparedQuery = datastore.prepare(q);
    return RetryHelper.runWithRetries(new Callable<List<Entity>>() {
      @Override
      public List<Entity> call() {
        List<Entity> list = preparedQuery.asList(withLimit(limit));
        list.size(); // Forces the loading of all the data.
        return list;
      }
    },RetryParams.getDefaultInstance(), EXCEPTION_HANDLER);
  }
View Full Code Here

    {
      return pq.asSingleEntity();
    }
    else
    {
      return pq.asList(fetchOptions).get(0);
    }
  }
 
 
  public static List<Entity> getEntities(Query query)
View Full Code Here

  public static List<Entity> getEntities(Query query)
  {
    DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
    PreparedQuery pq = ds.prepare(query);
   
    return pq.asList(FetchOptions.Builder.withDefaults());
  }
 
  public static int deleteAllEntityKind(String simpleClassName)
  {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
View Full Code Here

    this.keys = new ArrayList<>(result.keySet());

    // This should apply the writes
    Query q = new Query("Trivial");
    PreparedQuery pq = ds().prepare(q);
    pq.asList(FetchOptions.Builder.withDefaults());

    // For some reason this doesn't.
    ofy().load().keys(keys).size();
  }
View Full Code Here

    Trivial triv = new Trivial(123L, "foo", 12);
    ofy().save().entity(triv).now();

    Query q = new Query("Trivial");
    PreparedQuery pq = ds().prepare(q);
    List<Entity> stuff = pq.asList(FetchOptions.Builder.withDefaults());
    assert stuff.size() == 1;

    int count = 0;
    for (@SuppressWarnings("unused") Trivial fetched: ofy().load().type(Trivial.class)) {
      count++;
View Full Code Here

                q.setKeysOnly();

                q.addFilter(PROPERTY_EXPIRES,
                        FilterOperator.LESS_THAN_OR_EQUAL, expire);
                PreparedQuery pq = ds.prepare(q);
                List<Entity> entities = pq.asList(Builder
                        .withLimit(CLEANUP_LIMIT));
                if (entities != null) {
                    logger.info("Vaadin cleanup deleting " + entities.size()
                            + " expired Vaadin sessions.");
                    List<Key> keys = new ArrayList<Key>();
View Full Code Here

                Query q = new Query(APPENGINE_SESSION_KIND);
                q.setKeysOnly();
                q.addFilter(PROPERTY_APPENGINE_EXPIRES,
                        FilterOperator.LESS_THAN_OR_EQUAL, expire);
                PreparedQuery pq = ds.prepare(q);
                List<Entity> entities = pq.asList(Builder
                        .withLimit(CLEANUP_LIMIT));
                if (entities != null) {
                    logger.info("Vaadin cleanup deleting " + entities.size()
                            + " expired appengine sessions.");
                    List<Key> keys = new ArrayList<Key>();
View Full Code Here

    query.addSort("creation", SortDirection.DESCENDING);

    final DatastoreService datastore = DatastoreServiceFactory
        .getDatastoreService();
    final PreparedQuery pq = datastore.prepare(query);
    final List<Entity> entList = pq.asList(FetchOptions.Builder
        .withLimit(1));
    if (entList.size() > 0) {
      final String blobKeyString = entList.get(0).getKey().getName();
      return new BlobKey(blobKeyString);
    }
View Full Code Here

      query.addSort("rating", SortDirection.DESCENDING);

      final DatastoreService datastore = DatastoreServiceFactory
          .getDatastoreService();
      final PreparedQuery pq = datastore.prepare(query);
      final List<Entity> entList = pq.asList(FetchOptions.Builder
          .withDefaults());
      return entList;
    } finally {
      step.close();
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.