Examples of Painting


Examples of org.apache.cayenne.testdo.testmap.Painting

        q.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        RefreshQuery refresh = new RefreshQuery(q);
        context.performQuery(refresh);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        // probably refreshed eagerly
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        q.setCacheStrategy(QueryCacheStrategy.SHARED_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        RefreshQuery refresh = new RefreshQuery(q);
        context.performQuery(refresh);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        // probably refreshed eagerly
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        q.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
        q.setCacheGroups("X");
        List paints = context.performQuery(q);

        // fetch P1 separately from cached query
        Painting p1 = Cayenne.objectForPK(context, Painting.class, 33001);

        Painting p2 = (Painting) paints.get(0);
        Artist a1 = p2.getToArtist();
        assertSame(a1, p1.getToArtist());

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        createTestData("testRefreshCollectionToOneUpdate");

        // results are served from cache and therefore are not refreshed
        context.performQuery(q);
        assertSame(a1, p1.getToArtist());
        assertSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("c", p2.getToArtist().getArtistName());

        RefreshQuery refresh = new RefreshQuery("X");

        // this should invalidate results for the next query run
        context.performQuery(refresh);

        // this should force a refresh
        context.performQuery(q);

        assertEquals(PersistenceState.COMMITTED, p1.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, p2.getPersistenceState());

        assertSame(a1, p1.getToArtist());
        assertNotSame(a1, p2.getToArtist());
        assertEquals("c", p1.getToArtist().getArtistName());
        assertEquals("b", p2.getToArtist().getArtistName());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        q.addOrdering("db:ARTIST_ID", SortOrder.ASCENDING);
        List artists = context.performQuery(q);

        Artist a1 = (Artist) artists.get(0);
        Artist a2 = (Artist) artists.get(1);
        Painting p1 = a1.getPaintingArray().get(0);
        Painting p2 = a1.getPaintingArray().get(0);

        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a1.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a2.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNotNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        RefreshQuery refresh = new RefreshQuery();
        context.performQuery(refresh);

        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a1.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(a2.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p1.getObjectId()));
        assertNull(context
                .getParentDataDomain()
                .getSharedSnapshotCache()
                .getCachedSnapshot(p2.getObjectId()));

        assertEquals(PersistenceState.HOLLOW, a1.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, a2.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, p1.getPersistenceState());
        assertEquals(PersistenceState.HOLLOW, p2.getPersistenceState());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

    public void testRollbackNew() {
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName("a");

        Painting p1 = (Painting) context.newObject("Painting");
        p1.setPaintingTitle("p1");
        p1.setToArtist(artist);

        Painting p2 = (Painting) context.newObject("Painting");
        p2.setPaintingTitle("p2");
        p2.setToArtist(artist);

        Painting p3 = (Painting) context.newObject("Painting");
        p3.setPaintingTitle("p3");
        p3.setToArtist(artist);

        // before:
        assertEquals(artist, p1.getToArtist());
        assertEquals(3, artist.getPaintingArray().size());
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        String artistName = "rollbackTestArtist";
        String paintingTitle = "rollbackTestPainting";
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName(artistName);

        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle(paintingTitle);
        painting.setToArtist(artist);

        context.rollbackChanges();

        assertEquals(PersistenceState.TRANSIENT, artist.getPersistenceState());
        context.commitChanges();
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

    public void testRollbackRelationshipModification() {
        String artistName = "relationshipModArtist";
        String paintingTitle = "relationshipTestPainting";
        Artist artist = (Artist) context.newObject("Artist");
        artist.setArtistName(artistName);
        Painting painting = (Painting) context.newObject("Painting");
        painting.setPaintingTitle(paintingTitle);
        painting.setToArtist(artist);
        context.commitChanges();

        painting.setToArtist(null);
        assertEquals(0, artist.getPaintingArray().size());
        context.rollbackChanges();

        assertTrue(((ValueHolder) artist.getPaintingArray()).isFault());
        assertEquals(1, artist.getPaintingArray().size());
        assertEquals(artist, painting.getToArtist());

        // Check that the reverse relationship was handled
        assertEquals(1, artist.getPaintingArray().size());
        context.commitChanges();

        DataContext freshContext = (DataContext) serverRuntime.getContext();
        assertNotSame(this.context, freshContext);
       
        SelectQuery query = new SelectQuery(Painting.class);
        query.setQualifier(ExpressionFactory.matchExp("paintingTitle", paintingTitle));
        List queryResults = freshContext.performQuery(query);

        assertEquals(1, queryResults.size());
        Painting queriedPainting = (Painting) queryResults.get(0);

        // NB: This is an easier comparison than manually fetching artist
        assertEquals(artistName, queriedPainting.getToArtist().getArtistName());
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        c.add(Calendar.DAY_OF_MONTH, -1);
        Artist a3 = context.newObject(Artist.class);
        a3.setArtistName("3");
        a3.setDateOfBirth(c.getTime());

        Painting p1 = context.newObject(Painting.class);
        p1.setEstimatedPrice(new BigDecimal(1));
        p1.setPaintingTitle("Y");
        a1.addToPaintingArray(p1);

        Painting p2 = context.newObject(Painting.class);
        p2.setEstimatedPrice(new BigDecimal(2));
        p2.setPaintingTitle("X");
        a2.addToPaintingArray(p2);

        context.commitChanges();

        SelectQuery query1 = new SelectQuery(Artist.class);
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        Artist altA = context.newObject(Artist.class);

        Painting p = context.newObject(Painting.class);
        p.setToArtist(a);
        p.setPaintingTitle("PPP");
        a.setArtistName("X");
        altA.setArtistName("Y");
        context.commitChanges();

        DataContext parentPeer = createDataContextWithSharedCache(false);
        Painting p1 = (Painting) parentPeer.localObject(p.getObjectId(), p);
        Artist altA1 = (Artist) parentPeer.localObject(altA.getObjectId(), altA);

        final ObjectContext peer2 = context.createChildContext();
        final Painting p2 = (Painting) peer2.localObject(p.getObjectId(), p);
        final Artist altA2 = (Artist) peer2.localObject(altA.getObjectId(), altA);
        Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        p1.setToArtist(altA1);
        assertSame(a2, p2.getToArtist());
        assertNotSame(altA2, p2.getToArtist());
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertSame(altA2, p2.getToArtist());
                assertFalse("Peer data context became dirty on event processing", peer2
                        .hasChanges());
            }
        }.assertWithTimeout(2000);
    }
View Full Code Here

Examples of org.apache.cayenne.testdo.testmap.Painting

        DataContext context = createDataContext();

        Artist a = context.newObject(Artist.class);
        a.setArtistName("X");

        Painting px = context.newObject(Painting.class);
        px.setToArtist(a);
        px.setPaintingTitle("PX");

        Painting py = context.newObject(Painting.class);
        py.setPaintingTitle("PY");

        context.commitChanges();

        DataContext parentPeer = createDataContextWithSharedCache(false);
        Painting py1 = (Painting) parentPeer.localObject(py.getObjectId(), py);
        Artist a1 = (Artist) parentPeer.localObject(a.getObjectId(), a);

        final ObjectContext peer2 = context.createChildContext();
        final Painting py2 = (Painting) peer2.localObject(py.getObjectId(), py);
        final Artist a2 = (Artist) peer2.localObject(a.getObjectId(), a);

        a1.addToPaintingArray(py1);
        assertEquals(1, a2.getPaintingArray().size());
        assertFalse(a2.getPaintingArray().contains(py2));
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.