Package org.apache.cayenne.access

Examples of org.apache.cayenne.access.DataContext.performQuery()


        DataContext context = createDataContext();

        Expression qual = Expression.fromString("details.name like 'cd%'");
        SelectQuery query = new SelectQuery(ClobMaster.class, qual);
        List result = context.performQuery(query);

        assertEquals(3, result.size());
    }
}
View Full Code Here


        // Per CAY-1379 removing user and then refetching resulted in a FFE downstream
        group1.removeFromGroupMembers(user);
        Expression exp = ExpressionFactory.matchExp(Role.ROLE_GROUPS_PROPERTY, group2);
        SelectQuery query = new SelectQuery(Group.class, exp);
        context.performQuery(query);
        context.commitChanges();

        context.deleteObject(group1);
        context.deleteObject(group2);
        context.deleteObject(user);
View Full Code Here

    public void testPrefetchToOne() {
        DataContext ctxt = createDataContext();
        SelectQuery query = new SelectQuery(Painting.class);
        query.addPrefetch(Painting.TO_PAINTING_INFO_PROPERTY);
        List daos = ctxt.performQuery(query);
        assertTrue(!daos.isEmpty());
        for (Iterator it = daos.iterator(); it.hasNext();) {
            Painting p = (Painting) it.next();
            PaintingInfo pi = p.getToPaintingInfo();
            assertEquals("persistence state", PersistenceState.COMMITTED, p
View Full Code Here

        insertValue();
        DataContext contex = createDataContext();
        String ejbql = "select a FROM Artist a";
        EJBQLQuery query = new EJBQLQuery(ejbql);
        query.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
        List<Artist> artist1 = contex.performQuery(query);
        blockQueries();
        List<Artist> artist2;
        try {
            EJBQLQuery query1 = new EJBQLQuery(ejbql);
            query1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
View Full Code Here

        blockQueries();
        List<Artist> artist2;
        try {
            EJBQLQuery query1 = new EJBQLQuery(ejbql);
            query1.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
            artist2 = contex.performQuery(query1);
        }
        finally {
            unblockQueries();
        }
View Full Code Here

        DataContext contex = createDataContext();
       
        String ejbql = "SELECT p.toArtist FROM Painting p";
        EJBQLQuery query = new EJBQLQuery(ejbql);

        List result = contex.performQuery(query);

        assertNotNull(result);
        assertEquals(2, result.size());

        assertEquals(Artist.class, result.get(0).getClass());
View Full Code Here

       
        String ejbql2 = "SELECT p.toArtist, p FROM Painting p";
        EJBQLQuery query2 = new EJBQLQuery(ejbql2);

        List result2 = contex.performQuery(query2);

        assertNotNull(result2);
        assertEquals(2, result2.size());
        assertEquals(2, ((Object[])result2.get(0)).length);
       
View Full Code Here

        assertEquals(Painting.class,((Object[])result2.get(0))[1].getClass());
       
        String ejbql3 = "SELECT p.toArtist, p.paintingTitle FROM Painting p";
        EJBQLQuery query3 = new EJBQLQuery(ejbql3);

        List result3 = contex.performQuery(query3);

        assertNotNull(result3);
        assertEquals(2, result3.size());
        assertEquals(2, ((Object[])result3.get(0)).length);
       
View Full Code Here

       
        SelectQuery query = new SelectQuery(Artist.class);
        query.setStatementFetchSize(10);
       
        assertEquals(10, query.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
        dataContext.performQuery(query);
       
        SQLTemplate template = new SQLTemplate(Artist.class, "SELECT ARTIST_ID FROM ARTIST");
        template.setStatementFetchSize(10);
       
        assertEquals(10, template.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
View Full Code Here

       
        SQLTemplate template = new SQLTemplate(Artist.class, "SELECT ARTIST_ID FROM ARTIST");
        template.setStatementFetchSize(10);
       
        assertEquals(10, template.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
        dataContext.performQuery(template);
       
        EJBQLQuery ejbql = new EJBQLQuery("select a from Artist a");
        ejbql.setStatementFetchSize(10);
       
        assertEquals(10, ejbql.getMetaData(dataContext.getEntityResolver()).getStatementFetchSize());
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.