Package org.apache.cayenne

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


        ObjectContext context = createDataContext();
        UuidTestEntity test = context.newObject(UuidTestEntity.class);

        UUID id = UUID.randomUUID();
        test.setUuid(id);
        context.commitChanges();

        SelectQuery q = new SelectQuery(UuidTestEntity.class);
        UuidTestEntity testRead = (UuidTestEntity) context.performQuery(q).get(0);
        assertNotNull(testRead.getUuid());
        assertEquals(id, testRead.getUuid());
View Full Code Here


        UuidTestEntity testRead = (UuidTestEntity) context.performQuery(q).get(0);
        assertNotNull(testRead.getUuid());
        assertEquals(id, testRead.getUuid());

        test.setUuid(null);
        context.commitChanges();
    }
}
View Full Code Here

        SelectQuery q = new SelectQuery(Artist.class);
        List<Artist> allArtists = context.performQuery(q);

        Date dob = new Date();
        allArtists.get(0).setDateOfBirth(dob);
        context.commitChanges();

        String ejbql = "SELECT a FROM Artist a WHERE a.dateOfBirth = :x";

        EJBQLQuery query = new EJBQLQuery(ejbql);
        query.setParameter("x", dob);
View Full Code Here

        childDeleted.setArtistName("DDD");

        Artist childHollow = (Artist) objects.get(3);
        childContext.invalidateObjects(Collections.singleton(childHollow));

        childContext.commitChanges();

        assertEquals(PersistenceState.COMMITTED, childNew.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, childModified.getPersistenceState());
        assertEquals(PersistenceState.COMMITTED, childCommitted.getPersistenceState());
        assertEquals(PersistenceState.TRANSIENT, childDeleted.getPersistenceState());
View Full Code Here

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

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

        Painting p1 = child.newObject(Painting.class);
        p1.setPaintingTitle("P1");
        a.addToPaintingArray(p1);
View Full Code Here

        PrimitivesTestEntity e = context
                .newObject(PrimitivesTestEntity.class);
        e.setBooleanColumn(true);
        e.setIntColumn(88);
        context.commitChanges();
    }
}
View Full Code Here

        BigIntegerEntity o2 = context
                .newObject(BigIntegerEntity.class);
        o2.setBigIntegerField(new BigInteger("10"));

        context.commitChanges();

        EJBQLQuery query = new EJBQLQuery(
                "SELECT d FROM BigIntegerEntity d WHERE MOD(d.bigIntegerField, 4) = 2");
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());
View Full Code Here

        a2.addToPaintingArray(p12);
        Painting p22 = context.newObject(Painting.class);
        p22.setPaintingTitle("p22");
        a2.addToPaintingArray(p22);

        context.commitChanges();

        EJBQLQuery query = new EJBQLQuery(
                "SELECT d FROM Artist d WHERE SIZE(d.paintingArray) = 2");
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());
View Full Code Here

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("a1");

        Artist a2 = context.newObject(Artist.class);
        a2.setArtistName("a2");
        context.commitChanges();

        EJBQLQuery query = new EJBQLQuery(
                "SELECT a FROM Artist a WHERE CONCAT(a.artistName, a.artistName) = 'a1a1'");
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());
View Full Code Here

        Artist a1 = context.newObject(Artist.class);
        a1.setArtistName("12345678");

        Artist a2 = context.newObject(Artist.class);
        a2.setArtistName("abcdefg");
        context.commitChanges();

        EJBQLQuery query = new EJBQLQuery(
                "SELECT a FROM Artist a WHERE SUBSTRING(a.artistName, 2, 3) = 'bcd'");
        List objects = context.performQuery(query);
        assertEquals(1, objects.size());
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.