Package org.apache.cayenne

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


        //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 " +
            "a.artistName <> a.artistName or a.artistName = a.artistName");
        assertTrue(context.performQuery(query).size() > 0);

        //checking brackets around not
        query = new EJBQLQuery("select a from Artist a " +
            "where not(a.artistName <> a.artistName and " +
            "a.artistName <> a.artistName or a.artistName = a.artistName)");
View Full Code Here


        //checking brackets around not
        query = new EJBQLQuery("select a from Artist a " +
            "where not(a.artistName <> a.artistName and " +
            "a.artistName <> a.artistName or a.artistName = a.artistName)");
        assertEquals(context.performQuery(query).size(), 0);

        //not is first to process
        query = new EJBQLQuery("select a from Artist a " +
                "where not a.artistName <> a.artistName or " +
                "a.artistName = a.artistName");
View Full Code Here

        //not is first to process
        query = new EJBQLQuery("select a from Artist a " +
                "where not a.artistName <> a.artistName or " +
                "a.artistName = a.artistName");
        assertTrue(context.performQuery(query).size() > 0);
    }
}
View Full Code Here

        context.commitChanges();
        assertEquals(0, a1.getPostLoaded());
        assertNull(listener.getPublicCalledbackEntity());

        EJBQLQuery q = new EJBQLQuery("select a, a.artistName from Artist a");
        context.performQuery(q);
        assertEquals(1, a1.getPostLoaded());
        assertSame(a1, listener.getPublicCalledbackEntity());
    }

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

        // reset context and read related object
        context = createDataContext();

        SelectQuery q = new SelectQuery(Painting.class);
        p1 = (Painting) context.performQuery(q).get(0);

        // this should be a hollow object, so no callback just yet
        a1 = p1.getToArtist();
        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
        assertEquals(0, a1.getPostLoaded());
View Full Code Here

        // reset context and read related object
        context = createDataContext();

        SelectQuery q = new SelectQuery(Painting.class);
        q.addPrefetch(Painting.TO_ARTIST_PROPERTY);
        p1 = (Painting) context.performQuery(q).get(0);

        // artist is prefetched here, and a callback must have been invoked
        a1 = p1.getToArtist();
        assertEquals(PersistenceState.COMMITTED, a1.getPersistenceState());
        assertEquals(1, a1.getPostLoaded());
View Full Code Here

        context.commitChanges();
        assertEquals(0, a1.getPostLoaded());
        assertNull(listener.getPublicCalledbackEntity());

        SelectQuery q = new SelectQuery(Artist.class);
        context.performQuery(q);
        assertEquals(1, a1.getPostLoaded());
        assertSame(a1, listener.getPublicCalledbackEntity());

        a1.resetCallbackFlags();
        listener.reset();
View Full Code Here

        a1.resetCallbackFlags();
        listener.reset();
        assertEquals(0, a1.getPostLoaded());
        assertNull(listener.getPublicCalledbackEntity());

        context.performQuery(new RefreshQuery(a1));
        assertEquals(0, a1.getPostLoaded());
        assertNull(listener.getPublicCalledbackEntity());

        a1.getArtistName();
        assertEquals(1, a1.getPostLoaded());
View Full Code Here

        assertEquals(PersistenceState.COMMITTED, committed.getPersistenceState());
        assertEquals(PersistenceState.MODIFIED, modified.getPersistenceState());
        assertEquals(PersistenceState.DELETED, deleted.getPersistenceState());
        assertEquals(PersistenceState.NEW, _new.getPersistenceState());

        List objects = child.performQuery(new SelectQuery(Artist.class));
        assertEquals("All but NEW object must have been included", 4, objects.size());

        Iterator it = objects.iterator();
        while (it.hasNext()) {
            DataObject next = (DataObject) it.next();
View Full Code Here

        assertEquals(PersistenceState.NEW, newTarget.getPersistenceState());

        // run an ordered query, so we can address specific objects directly by index
        SelectQuery q = new SelectQuery(Painting.class);
        q.addOrdering(Painting.PAINTING_TITLE_PROPERTY, SortOrder.ASCENDING);
        List childSources = child.performQuery(q);
        assertEquals(5, childSources.size());

        blockQueries();
        try {
            Painting childHollowTargetSrc = (Painting) childSources.get(0);
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.