Examples of registerNewObject()


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

        ObjectContext context = createContext();
        Continent continent = context.newObject(Continent.class);
        continent.setName("Europe");
       
        Country country = new Country();
        context.registerNewObject(country);
       
        //TODO: setting property before object creation does not work on ROP (CAY-1320)
        country.setName("Russia");
       
        country.setContinent(continent);
View Full Code Here

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

        ObjectContext context = createContext();
        Continent continent = context.newObject(Continent.class);
        continent.setName("Europe");

        Country country = new Country();
        context.registerNewObject(country);

        // TODO: setting property before object creation does not work on ROP (CAY-1320)
        country.setName("Russia");

        country.setContinent(continent);
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        DataContext context = createDataContext();

        DataObject object = new Artist();
        assertNull(object.getObjectId());

        context.registerNewObject(object);
        ObjectId tempID = object.getObjectId();
        assertNotNull(tempID);
        assertTrue(tempID.isTemporary());
        assertSame(context, object.getObjectContext());
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        assertNotNull(tempID);
        assertTrue(tempID.isTemporary());
        assertSame(context, object.getObjectContext());

        // double registration in the same context should be quietly ignored
        context.registerNewObject(object);
        assertSame(tempID, object.getObjectId());
        assertSame(object, context.getGraphManager().getNode(tempID));

        // registering in another context should throw an exception
        DataContext anotherContext = createDataContext();
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        assertSame(object, context.getGraphManager().getNode(tempID));

        // registering in another context should throw an exception
        DataContext anotherContext = createDataContext();
        try {
            anotherContext.registerNewObject(object);
            fail("registerNewObject should've failed - object is already in another context");
        }
        catch (IllegalStateException e) {
            // expected
        }
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        DataContext context = createDataContext();

        Artist a = new Artist();
        assertNull(a.getObjEntity());

        context.registerNewObject(a);
        ObjEntity e = a.getObjEntity();
        assertNotNull(e);
        assertEquals("Artist", e.getName());

        Painting p = new Painting();
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        assertEquals("Artist", e.getName());

        Painting p = new Painting();
        assertNull(p.getObjEntity());

        context.registerNewObject(p);
        ObjEntity e1 = p.getObjEntity();
        assertNotNull(e1);
        assertEquals("Painting", e1.getName());
    }
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        DataContext context = createDataContext();

        Artist o1 = new Artist();
        assertNull(o1.getObjectId());

        context.registerNewObject(o1);
        assertNotNull(o1.getObjectId());
    }

    public void testStateTransToNew() {
        DataContext context = createDataContext();
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

    public void testStateTransToNew() {
        DataContext context = createDataContext();
        Artist o1 = new Artist();
        assertEquals(PersistenceState.TRANSIENT, o1.getPersistenceState());

        context.registerNewObject(o1);
        assertEquals(PersistenceState.NEW, o1.getPersistenceState());
    }

    public void testStateNewToCommitted() {
        DataContext context = createDataContext();
View Full Code Here

Examples of org.apache.cayenne.access.DataContext.registerNewObject()

        DataContext context = createDataContext();

        Artist o1 = new Artist();
        o1.setArtistName("a");

        context.registerNewObject(o1);
        assertEquals(PersistenceState.NEW, o1.getPersistenceState());

        context.commitChanges();
        assertEquals(PersistenceState.COMMITTED, o1.getPersistenceState());
    }
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.