Examples of Painting


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

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

        Painting p1 = child.newObject(Painting.class);
        p1.setPaintingTitle("P1");
        a.addToPaintingArray(p1);

        Painting p2 = child.newObject(Painting.class);
        p2.setPaintingTitle("P2");
        a.addToPaintingArray(p2);

        a.removeFromPaintingArray(p2);

        // this causes an error on commit
View Full Code Here

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

       
        Artist artist = context.newObject(Artist.class);
        artist.setArtistName("111");
        ObjectContext child = context.createChildContext();
       
        Painting painting = child.newObject(Painting.class);
        painting.setPaintingTitle("222");
       
        Artist localParentMt = (Artist) child.localObject(artist.getObjectId(), null);
        assertEquals(0, artist.getPaintingArray().size());
        assertEquals(0, localParentMt.getPaintingArray().size());
       
        painting.setToArtist(localParentMt);
       
        assertEquals(0, artist.getPaintingArray().size());
        assertEquals(1, localParentMt.getPaintingArray().size());
        assertEquals(localParentMt.getPaintingArray().get(0).getObjectContext(), child);
       
View Full Code Here

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

        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                512), null);
        assertEquals("No Painting Like This", p.getPaintingTitle());
    }
View Full Code Here

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

        assertNotNull(counts);
        assertEquals(1, counts.length);
        assertEquals(1, counts[0]);

        Painting p = (Painting) context.localObject(new ObjectId(
                "Painting",
                Painting.PAINTING_ID_PK_COLUMN,
                300), null);
        assertEquals("Go Figure", p.getPaintingTitle());
    }
View Full Code Here

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

    }

    public void testInvalidateRootWithChangedToOneTarget() throws Exception {
        createTwoArtistsAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);
        Artist artistBefore = painting.getToArtist();
        assertNotNull(artistBefore);
        assertEquals("artist2", artistBefore.getArtistName());

        assertEquals(1, tPainting.update().set("ARTIST_ID", 6).execute());

        context.invalidateObjects(Collections.singletonList(painting));
        assertNotSame(artistBefore, painting.getToArtist());
        assertEquals("artist3", painting.getToArtist().getArtistName());
    }
View Full Code Here

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

    }

    public void testInvalidateRootWithNullToOneTargetChangedToNotNull() throws Exception {
        createSingleArtistAndUnrelatedPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);
        assertNull(painting.getToArtist());

        assertEquals(1, tPainting.update().set("ARTIST_ID", 5).execute());

        context.invalidateObjects(Collections.singletonList(painting));
        assertNotNull(painting.getToArtist());
        assertEquals("artist2", painting.getToArtist().getArtistName());
    }
View Full Code Here

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

    public void testModifyHollow() throws Exception {

        createSingleArtistAndPaintingDataSet();

        Painting painting = (Painting) context.performQuery(
                new SelectQuery(Painting.class)).get(0);
        final Artist artist = painting.getToArtist();
        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
        assertNull(artist.readPropertyDirectly("artistName"));

        int queries = queryInterceptor.runWithQueryCounter(new UnitTestClosure() {
View Full Code Here

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

        ToManyList list = createForNewArtist();
        assertFalse("Expected resolved list when created with a new object", list
                .isFault());
        assertEquals(0, list.size());

        Painting p1 = context.newObject(Painting.class);
        list.add(p1);
        assertEquals(1, list.size());

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertEquals(2, list.size());

        list.remove(p1);
        assertEquals(1, list.size());
View Full Code Here

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

        // bypassing normal CayenneDataObject methods
        list.getRelationshipOwner().setPersistenceState(PersistenceState.MODIFIED);

        assertTrue("List must be unresolved for an existing object", list.isFault());

        Painting p1 = context.newObject(Painting.class);
        list.add(p1);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p1));

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p2));

        list.remove(p1);
View Full Code Here

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

    }

    public void testSavedUnresolvedMerge() throws Exception {
        ToManyList list = createForExistingArtist();

        Painting p1 = context.newObject(Painting.class);
        p1.setPaintingTitle("p1");

        // list being tested is a separate copy from
        // the relationship list that Artist has, so adding a painting
        // here will not add the painting to the array being tested
        ((Artist) list.getRelationshipOwner()).addToPaintingArray(p1);
        context.commitChanges();

        // immediately tag Artist as MODIFIED, since we are messing up with relationship
        // bypassing normal CayenneDataObject methods
        list.getRelationshipOwner().setPersistenceState(PersistenceState.MODIFIED);

        assertTrue("List must be unresolved...", list.isFault());
        list.add(p1);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p1));

        Painting p2 = context.newObject(Painting.class);
        list.add(p2);
        assertTrue("List must be unresolved when adding an object...", list.isFault());
        assertTrue(addedToUnresolved(list).contains(p2));

        // now resolve the list and see how merge worked
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.