Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.PropertyProjection


            .withProperty("group", "z")
            .store();

        Query query = new Query("Product")
            .setAncestor(key)
            .addProjection(new PropertyProjection("name", String.class))
            .addProjection(new PropertyProjection("price", Long.class));
        assertResultsInOrder(query, a1, b1, c1, c2);

        query = new Query("Product")
            .setAncestor(key)
            .addProjection(new PropertyProjection("name", String.class))
            .addProjection(new PropertyProjection("group", String.class))
            .addProjection(new PropertyProjection("price", Long.class));
        assertResultsInOrder(query, c1, c2, b1, a1);
    }
View Full Code Here


            .withProperty("price", 2L)
            .store();

        Query query = new Query("Product")
            .setAncestor(key)
            .addProjection(new PropertyProjection("price", Long.class))
            .setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("a", "b")));
        assertResultsInOrder(query, a, b);

        query = query.setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("b", "a")));
        assertResultsInOrder(query, b, a);
View Full Code Here

            .withProperty("price", 2L)
            .store();

        Query query = new Query("Product")
            .setAncestor(key)
            .addProjection(new PropertyProjection("price", Long.class))
            .setFilter(new Query.FilterPredicate("name", IN, Arrays.asList("a", "b")));
        Entity firstResult = service.prepare(query).asList(FetchOptions.Builder.withDefaults()).get(0);

        assertEquals(1, firstResult.getProperties().size());
        assertEquals("price", firstResult.getProperties().keySet().iterator().next());
View Full Code Here

    protected List<Entity> doQuery(String kind, String pName, Class<?> type, boolean indexed) {
        FetchOptions fo = FetchOptions.Builder.withDefaults();
        Query query = new Query(kind, rootKey);
        if (indexed) {
            query.addProjection(new PropertyProjection(pName, type));
            query.addSort(pName);
        }
        return service.prepare(query).asList(fo);
    }
View Full Code Here

    }

    @Test
    public void testDistinctStr() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.setDistinct(true);
        assertTrue(query.getDistinct());
        // distinct false
        query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.setDistinct(false);
        assertEquals(count, service.prepare(query).countEntities(fo));
        assertFalse(query.getDistinct());
    }
View Full Code Here

    }

    @Test
    public void testDistinctNum() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.setDistinct(true);
        assertEquals(4, service.prepare(query).countEntities(fo));
        assertTrue(query.getDistinct());
        query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.setDistinct(false);
        assertEquals(count, service.prepare(query).countEntities(fo));
        assertFalse(query.getDistinct());
    }
View Full Code Here

    }

    @Test
    public void testDistinctList() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("intList", Integer.class));
        query.setDistinct(true);
        assertEquals(24, service.prepare(query).countEntities(fo));
        assertTrue(query.getDistinct());
        // distinct false
        query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("intList", Integer.class));
        query.setDistinct(false);
        // 3 cols * 30 rows
        assertEquals(count * 3, service.prepare(query).countEntities(fo));
        assertFalse(query.getDistinct());
    }
View Full Code Here

    }

    @Test
    public void testDistinctMix() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.setDistinct(true);
        assertEquals(7, service.prepare(query).countEntities(fo));
        assertTrue(query.getDistinct());
        // distinct false
        query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.setDistinct(false);
        assertEquals(count, service.prepare(query).countEntities(fo));
        assertFalse(query.getDistinct());
    }
View Full Code Here

    }

    @Test
    public void testDistinctSort() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.addSort("stringData", Query.SortDirection.DESCENDING);
        query.setDistinct(true);
        assertEquals(7, service.prepare(query).countEntities(fo));
        assertTrue(query.getDistinct());
        query.addSort("floatData", Query.SortDirection.DESCENDING);
View Full Code Here

    }

    @Test
    public void testDistinctFilter() {
        Query query = new Query(kindName, rootKey);
        query.addProjection(new PropertyProjection("stringData", String.class));
        query.addProjection(new PropertyProjection("floatData", Float.class));
        query.setFilter(new FilterPredicate("stringData", Query.FilterOperator.NOT_EQUAL, "string1"));
        query.addSort("stringData", Query.SortDirection.DESCENDING);
        query.setDistinct(true);
        assertEquals(5, service.prepare(query).countEntities(fo));
        assertTrue(query.getDistinct());
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.PropertyProjection

Copyright © 2018 www.massapicom. 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.