Package org.apache.cayenne.testdo.relationship

Examples of org.apache.cayenne.testdo.relationship.ToOneFK1


        dbHelper.deleteAll("TO_ONEFK2");
    }

    public void testReadRelationship() {
        ToOneFK2 src = context.newObject(ToOneFK2.class);
        ToOneFK1 target = context.newObject(ToOneFK1.class);
        src.setToOneToFK(target);
        context.commitChanges();

        context.invalidateObjects(src, target);

        ToOneFK2 src1 = (ToOneFK2) Cayenne.objectForPK(context, src.getObjectId());
        assertNotNull(src1.getToOneToFK());
        // resolve HOLLOW
        assertSame(src1, src1.getToOneToFK().getToPK());

        context.invalidateObjects(src1, src1.getToOneToFK());

        ToOneFK1 target2 = (ToOneFK1) Cayenne.objectForPK(context, target.getObjectId());
        assertNotNull(target2.getToPK());

        // resolve HOLLOW
        assertSame(target2, target2.getToPK().getToOneToFK());
    }
View Full Code Here


    public void testReplaceNull2() throws Exception {
        ToOneFK2 src = context.newObject(ToOneFK2.class);
        context.commitChanges();

        ToOneFK1 target = context.newObject(ToOneFK1.class);

        // *** TESTING THIS ***
        src.setToOneToFK(target);

        // test before save
        assertSame(target, src.getToOneToFK());

        // do save
        context.commitChanges();

        // test database data
        ObjectIdQuery refetch = new ObjectIdQuery(
                src.getObjectId(),
                false,
                ObjectIdQuery.CACHE_REFRESH);
        ToOneFK2 src2 = (ToOneFK2) Cayenne.objectForQuery(context1, refetch);
        ToOneFK1 target2 = src2.getToOneToFK();
        assertNotNull(target2);
        assertEquals(src.getObjectId(), src2.getObjectId());
        assertEquals(target.getObjectId(), target2.getObjectId());
    }
View Full Code Here

        assertEquals(target.getObjectId(), target2.getObjectId());
    }

    public void testNewAdd() throws Exception {
        ToOneFK2 src = context.newObject(ToOneFK2.class);
        ToOneFK1 target = context.newObject(ToOneFK1.class);

        // *** TESTING THIS ***
        src.setToOneToFK(target);

        // test before save
        assertSame(target, src.getToOneToFK());

        // do save
        context.commitChanges();

        // test database data
        ObjectIdQuery refetch = new ObjectIdQuery(
                src.getObjectId(),
                false,
                ObjectIdQuery.CACHE_REFRESH);
        ToOneFK2 src2 = (ToOneFK2) Cayenne.objectForQuery(context1, refetch);
        ToOneFK1 target2 = src2.getToOneToFK();
        assertNotNull(target2);
        assertEquals(src.getObjectId(), src2.getObjectId());
        assertEquals(target.getObjectId(), target2.getObjectId());
    }
View Full Code Here

        assertEquals(target.getObjectId(), target2.getObjectId());
    }

    public void testTakeObjectSnapshotDependentFault() throws Exception {
        ToOneFK2 src = context.newObject(ToOneFK2.class);
        ToOneFK1 target = context.newObject(ToOneFK1.class);
        src.setToOneToFK(target);
        context.commitChanges();

        ObjectIdQuery refetch = new ObjectIdQuery(
                src.getObjectId(),
View Full Code Here

        assertTrue(src2.readPropertyDirectly("toOneToFK") instanceof Fault);
    }

    public void testDelete() throws Exception {
        ToOneFK2 src = context.newObject(ToOneFK2.class);
        ToOneFK1 target = context.newObject(ToOneFK1.class);
        src.setToOneToFK(target);
        context.commitChanges();

        src.setToOneToFK(null);
        context.deleteObjects(target);
View Full Code Here

TOP

Related Classes of org.apache.cayenne.testdo.relationship.ToOneFK1

Copyright © 2018 www.massapicom. 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.