Package org.apache.cayenne

Examples of org.apache.cayenne.CayenneDataObject


        SelectQuery q = new SelectQuery(CompoundFkTestEntity.class, e);
        q.addPrefetch("toCompoundPk");

        List objects = context.performQuery(q);
        assertEquals(1, objects.size());
        CayenneDataObject fk1 = (CayenneDataObject) objects.get(0);

        blockQueries();
        try {

            Object toOnePrefetch = fk1.readNestedProperty("toCompoundPk");
            assertNotNull(toOnePrefetch);
            assertTrue(
                    "Expected DataObject, got: " + toOnePrefetch.getClass().getName(),
                    toOnePrefetch instanceof DataObject);
View Full Code Here


        SelectQuery q = new SelectQuery(CompoundPkTestEntity.class, e);
        q.addPrefetch("compoundFkArray");

        List pks = context.performQuery(q);
        assertEquals(1, pks.size());
        CayenneDataObject pk1 = (CayenneDataObject) pks.get(0);

        List toMany = (List) pk1.readPropertyDirectly("compoundFkArray");
        assertNotNull(toMany);
        assertFalse(((ValueHolder) toMany).isFault());
        assertEquals(2, toMany.size());

        CayenneDataObject fk1 = (CayenneDataObject) toMany.get(0);
        assertEquals(PersistenceState.COMMITTED, fk1.getPersistenceState());

        CayenneDataObject fk2 = (CayenneDataObject) toMany.get(1);
        assertEquals(PersistenceState.COMMITTED, fk2.getPersistenceState());
    }
View Full Code Here

        try {
            sourceMap.addDbEntity(dbEntity);
            sourceMap.addObjEntity(objEntity);

            for (int i = 0; i < 5; i++) {
                CayenneDataObject dao = (CayenneDataObject) ctxt.newObject(objEntity
                        .getName());
                dao.writeProperty(oatr1.getName(), "test " + i);
            }
            ctxt.commitChanges();
        }
        finally {
            sourceMap.removeObjEntity(objEntity.getName(), true);
View Full Code Here

    }

    public void testProcessTemplateID() throws Exception {
        String sqlTemplate = "SELECT * FROM ME WHERE COLUMN1 = #bind($helper.cayenneExp($a, 'db:ID_COLUMN'))";

        DataObject dataObject = new CayenneDataObject();
        dataObject.setObjectId(new ObjectId("T", "ID_COLUMN", 5));

        Map map = Collections.singletonMap("a", dataObject);

        SQLStatement compiled = new SQLTemplateProcessor().processTemplate(
                sqlTemplate,
View Full Code Here

        Map idMap = new HashMap();
        idMap.put("ID_COLUMN1", new Integer(3));
        idMap.put("ID_COLUMN2", "aaa");
        ObjectId id = new ObjectId("T", idMap);
        DataObject dataObject = new CayenneDataObject();
        dataObject.setObjectId(id);

        Map map = Collections.singletonMap("a", dataObject);

        SQLStatement compiled = new SQLTemplateProcessor().processTemplate(
                sqlTemplate,
View Full Code Here

        SelectQuery q = new SelectQuery(CompoundFkTestEntity.class, e);
        q.addPrefetch("toCompoundPk");

        List objects = context.performQuery(q);
        assertEquals(1, objects.size());
        CayenneDataObject fk1 = (CayenneDataObject) objects.get(0);

        blockQueries();
        try {

            Object toOnePrefetch = fk1.readNestedProperty("toCompoundPk");
            assertNotNull(toOnePrefetch);
            assertTrue(
                    "Expected DataObject, got: " + toOnePrefetch.getClass().getName(),
                    toOnePrefetch instanceof DataObject);
View Full Code Here

        SelectQuery q = new SelectQuery(CompoundPkTestEntity.class, e);
        q.addPrefetch("compoundFkArray");

        List pks = context.performQuery(q);
        assertEquals(1, pks.size());
        CayenneDataObject pk1 = (CayenneDataObject) pks.get(0);

        List toMany = (List) pk1.readPropertyDirectly("compoundFkArray");
        assertNotNull(toMany);
        assertFalse(((ValueHolder) toMany).isFault());
        assertEquals(2, toMany.size());

        CayenneDataObject fk1 = (CayenneDataObject) toMany.get(0);
        assertEquals(PersistenceState.COMMITTED, fk1.getPersistenceState());

        CayenneDataObject fk2 = (CayenneDataObject) toMany.get(1);
        assertEquals(PersistenceState.COMMITTED, fk2.getPersistenceState());
    }
View Full Code Here

            List result = context.performQuery(q);

            blockQueries();
            try {
                assertFalse(result.isEmpty());
                CayenneDataObject a1 = (CayenneDataObject) result.get(0);
                List toMany = (List) a1.readPropertyDirectly("paintingArray");
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
            }
            finally {
                unblockQueries();
View Full Code Here

            blockQueries();

            try {
                assertFalse(result.isEmpty());

                CayenneDataObject a1 = (CayenneDataObject) result.get(0);
                List toMany = (List) a1.readPropertyDirectly("paintingArray");
                assertNotNull(toMany);
                assertFalse(((ValueHolder) toMany).isFault());
            }
            finally {
                unblockQueries();
View Full Code Here

        final AuditableFilter filter = new AuditableFilter(resolver, processor);
        ObjectContext context = mock(ObjectContext.class);
        GraphDiff changes = mock(GraphDiff.class);

        final DataObject auditedParent1 = new CayenneDataObject();
        final DataObject audited11 = new MockAuditableChild();
        audited11.writeProperty("parent", auditedParent1);
        final DataObject audited12 = new MockAuditableChild();
        audited12.writeProperty("parent", auditedParent1);
        final DataObject audited13 = new MockAuditableChild();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.CayenneDataObject

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.