Package com.google.appengine.api.datastore

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


     * @return Entities
     */
    private static List<Entity> queryMetaData(DatastoreService service, FetchOptions options, String metaDataQuery) {
        Query query = new Query(metaDataQuery);
        PreparedQuery preparedQuery = service.prepare(query);
        return preparedQuery.asList(options);
    }

    /**
     * Queries for meta data.
     *
 
View Full Code Here


     */
    private static List<Entity> queryMetaData(DatastoreService service, FetchOptions options, String metaDataQuery, Closure<?> closure) {
        Query query = new Query(metaDataQuery);
        closure.call(query);
        PreparedQuery preparedQuery = service.prepare(query);
        return preparedQuery.asList(options);
    }

    /**
     * Creates kind key
     *
 
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

    private List<DomainEventMessage> readEventSegmentInternal(String type, Object identifier,
                                                              long firstSequenceNumber) {
        Query query = EventEntry.forAggregate(type, identifier.toString(), firstSequenceNumber);
        PreparedQuery preparedQuery = datastoreService.prepare(query);
        List<Entity> entities = preparedQuery.asList(FetchOptions.Builder.withDefaults());

        List<DomainEventMessage> events = new ArrayList<DomainEventMessage>(entities.size());
        for (Entity entity : entities) {
            events.addAll(new EventEntry(entity).getDomainEvent(identifier, eventSerializer, upcasterChain, false));
        }
View Full Code Here

            .setAncestor(key)
            .addProjection(new PropertyProjection("prop", String.class))
            .addSort("prop");

        PreparedQuery preparedQuery = service.prepare(query);
        List<Entity> results = preparedQuery.asList(withDefaults());
        assertEquals(3, results.size());

        Entity firstResult = results.get(0);
        Entity secondResult = results.get(1);
        Entity thirdResult = results.get(2);
View Full Code Here

            .setFilter(new Query.FilterPredicate("price", GREATER_THAN, 0L))
            .addSort("price")
            .addSort("name");

        PreparedQuery preparedQuery = service.prepare(query);
        List<Entity> results = preparedQuery.asList(withDefaults());
        assertEquals(4, results.size());

        assertEquals(e.getKey(), results.get(0).getKey());
        assertEquals(e.getKey(), results.get(1).getKey());
        assertEquals(e.getKey(), results.get(2).getKey());
View Full Code Here

        Query query = new Query("foo")
            .setAncestor(parentKey)
            .setFilter(new Query.FilterPredicate(Entity.KEY_RESERVED_PROPERTY, EQUAL, fooKey));

        PreparedQuery preparedQuery = service.prepare(query);
        List<Entity> results = preparedQuery.asList(FetchOptions.Builder.withDefaults());

        assertEquals(1, results.size());
        assertEquals(fooEntity, results.get(0));
    }
View Full Code Here

        service.put(address);

        PreparedQuery preparedQuery = service.prepare(new Query().setAncestor(parentKey));
        assertTrue(preparedQuery.countEntities(withDefaults()) >= 2);

        List<Entity> results = preparedQuery.asList(withDefaults());
        assertTrue(results.containsAll(Arrays.asList(person, address)));
    }

    @Test
    public void queryingByKindOnlyReturnsEntitiesOfRequestedKind() throws Exception {
View Full Code Here

        Key parentKey = createQueryBasicsTestParent("testFilteringByKind");
        Entity foo = createEntity("foo", parentKey).store();
        Entity bar = createEntity("bar", parentKey).store();

        PreparedQuery preparedQuery = service.prepare(new Query("foo").setAncestor(parentKey));
        List<Entity> results = preparedQuery.asList(withDefaults());
        assertEquals(1, results.size());
        assertEquals(foo, results.get(0));
    }

    @Test
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.