Package org.apache.cayenne

Examples of org.apache.cayenne.ObjectContext.performQuery()


        ObjectContext childContext = context.createChildContext();

        // make sure we fetch in predictable order
        SelectQuery query = new SelectQuery(Artist.class);
        query.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
        List objects = childContext.performQuery(query);

        assertEquals(4, objects.size());

        Artist childNew = childContext.newObject(Artist.class);
        childNew.setArtistName("NNN");
View Full Code Here


                        }
                }
            };
   
            test.test(q);
            context.performQuery(q);           
           
            //testing outer join!!
            q = new SelectQuery(Painting.class);
            q.addOrdering("toArtist+.artistName", SortOrder.ASCENDING);
            test.test(q);
View Full Code Here

           
            //testing outer join!!
            q = new SelectQuery(Painting.class);
            q.addOrdering("toArtist+.artistName", SortOrder.ASCENDING);
            test.test(q);
            context.performQuery(q);
           
            //testing quering from related table
            q = new SelectQuery(Painting.class,
                    ExpressionFactory.matchExp("toArtist.artistName", "foo"));
            test.test(q);
View Full Code Here

           
            //testing quering from related table
            q = new SelectQuery(Painting.class,
                    ExpressionFactory.matchExp("toArtist.artistName", "foo"));
            test.test(q);
            context.performQuery(q);
           
            //testing flattened rels
            q = new SelectQuery(Artist.class, ExpressionFactory.matchExp("groupArray.name", "bar"));
            new Template() {
                @Override
View Full Code Here

                @Override
                void test(SelectTranslator transl) throws Exception {
                    assertTrue(transl.createSqlString().indexOf("GROUP_ID = ") > 0);
                }
            }.test(q);
            context.performQuery(q);
        }
        finally {
            entity.setQualifier(null);
            middleEntity.setQualifier(null);
        }
View Full Code Here

    public void testJoinToJoined() {
        ObjectContext context = createDataContext();

        EJBQLQuery query = new EJBQLQuery(
            "select g from Gallery g inner join g.paintingArray p where p.toArtist.artistName like '%a%'");
        context.performQuery(query);
    }



    public void testJoinAndCount() {
View Full Code Here

        EJBQLQuery query = new EJBQLQuery(
            "select count(p) from Painting p where p.toGallery.galleryName LIKE '%a%' AND (" +
            "p.paintingTitle like '%a%' or " +
            "p.toArtist.artistName like '%a%'" +
            ")");
        context.performQuery(query);
    }

//    SELECT COUNT(p) from Product p where p.vsCatalog.id = 1 and
//    (
//    p.displayName like '%rimadyl%'
View Full Code Here

        EJBQLQuery query = new EJBQLQuery(
            "select p from Painting p where p.toArtist=:a");
        query.setParameter("a", a);

        List<Painting> paintings = context.performQuery(query);
        assertEquals(1, paintings.size());
        assertSame(p, paintings.get(0));
    }

    public void testRelationshipWhereClause2() throws Exception {
View Full Code Here

        ObjectContext context = createDataContext();

        Expression exp = ExpressionFactory.matchExp(Painting.TO_GALLERY_PROPERTY, null);
        EJBQLQuery query = new EJBQLQuery("select p.toArtist from Painting p where " + exp.toEJBQL("p"));

        context.performQuery(query);
    }

    public void testOrBrackets() throws Exception {
        deleteTestData();
        ObjectContext context = createDataContext();
View Full Code Here

        //this query is equivalent to (false and (false or true)) and
        //should always return 0 rows
        EJBQLQuery query = new EJBQLQuery("select a from Artist a " +
        "where a.artistName <> a.artistName and " +
        "(a.artistName <> a.artistName or a.artistName = a.artistName)");
        assertEquals(context.performQuery(query).size(), 0);

        //on the other hand, the following is equivalent to (false and false) or true) and
        //should return >0 rows
        query = new EJBQLQuery("select a from Artist a " +
            "where a.artistName <> a.artistName and " +
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.