Package org.apache.cayenne

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


    public void testRelate_New() throws Exception {

        ObjectContext context = runtime.getContext();
        E1 e1 = context.newObject(E1.class);

        UuidRoot1 r1 = context.newObject(UuidRoot1.class);

        ReferenceableHandler refHandler = new ReferenceableHandler(context
                .getEntityResolver());
        UuidRelationshipHandler handler = new UuidRelationshipHandler(refHandler);
        handler.relate(r1, e1);
View Full Code Here


        ObjectContext context = runtime.getContext();

        UuidRoot1 r1 = Cayenne.objectForPK(context, UuidRoot1.class, 1);
        assertEquals("E1:1", r1.getUuid());

        E1 e1 = context.newObject(E1.class);

        ReferenceableHandler refHandler = new ReferenceableHandler(context
                .getEntityResolver());
        UuidRelationshipHandler handler = new UuidRelationshipHandler(refHandler);
        handler.relate(r1, e1);
View Full Code Here

    }

    public void testChangeEventOnPeerChangeSecondNestingLevel() throws Exception {
        ObjectContext childPeer1 = context.createChildContext();

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

        final MockChannelListener listener = new MockChannelListener();
        EventUtil.listenForChannelEvents((DataChannel) childPeer1, listener);
View Full Code Here

    @Inject
    private DataContext context;

    public void testPeerObjectUpdatedTempOID() {
        ObjectContext peer1 = context.createChildContext();
        Artist a1 = peer1.newObject(Artist.class);
        a1.setArtistName("Y");
        ObjectId a1TempId = a1.getObjectId();

        ObjectContext peer2 = context.createChildContext();
        Artist a2 = (Artist) peer2.localObject(a1TempId, a1);
View Full Code Here

        DataContext context = createDataContext();
        ObjectContext childContext = context.createChildContext();

        Artist a = Cayenne.objectForPK(childContext, Artist.class, 33001);
        Painting p = childContext.newObject(Painting.class);
        p.setPaintingTitle("X");
        a.addToPaintingArray(p);

        childContext.commitChangesToParent();
View Full Code Here

        query.addOrdering(Artist.ARTIST_NAME_PROPERTY, SortOrder.ASCENDING);
        List<?> objects = childContext.performQuery(query);

        assertEquals(4, objects.size());

        final Artist childNew = childContext.newObject(Artist.class);
        childNew.setArtistName("NNN");

        final Artist childModified = (Artist) objects.get(0);
        childModified.setArtistName("MMM");
View Full Code Here

        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");

        Artist childModified = (Artist) objects.get(0);
        childModified.setArtistName("MMM");
View Full Code Here

    public void testCommitChangesToParentPropagatedKey() throws Exception {
        final DataContext context = createDataContext();
        final ObjectContext childContext = context.createChildContext();

        final Painting childMaster = childContext.newObject(Painting.class);
        childMaster.setPaintingTitle("Master");

        final PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
        childDetail1.setTextReview("Detail1");
        childDetail1.setPainting(childMaster);
View Full Code Here

        final ObjectContext childContext = context.createChildContext();

        final Painting childMaster = childContext.newObject(Painting.class);
        childMaster.setPaintingTitle("Master");

        final PaintingInfo childDetail1 = childContext.newObject(PaintingInfo.class);
        childDetail1.setTextReview("Detail1");
        childDetail1.setPainting(childMaster);

        queryInterceptor.runWithQueriesBlocked(new UnitTestClosure() {
View Full Code Here

    public void testCommitChangesToParentFlattened() throws Exception {

        final DataContext context = createDataContext();
        final ObjectContext childContext = context.createChildContext();

        final Artist childO1 = childContext.newObject(Artist.class);
        childO1.setArtistName("Master");

        final ArtGroup childO2 = childContext.newObject(ArtGroup.class);
        childO2.setName("Detail1");
        childO2.addToArtistArray(childO1);
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.