Package org.apache.cayenne

Examples of org.apache.cayenne.ObjectId


            // link with parent

            // The algorithm below of building an ID doesn't take inheritance into
            // account, so there maybe a miss...
            ObjectId id = createObjectId(row, sourceObjEntity, relatedIdPrefix);
            Persistent parentObject = (Persistent) context.getObjectStore().getNode(id);

            // don't attach to hollow objects
            if (parentObject != null
                    && parentObject.getPersistenceState() != PersistenceState.HOLLOW) {
View Full Code Here


            classDescriptor = descriptor;
        }

        // not using DataRow.createObjectId for performance reasons - ObjectResolver has
        // all needed metadata already cached.
        ObjectId anId = createObjectId(row, classDescriptor.getEntity(), null);

        // this will create a HOLLOW object if it is not registered yet
        Persistent object = context.localObject(anId, null);

        // deal with object state
View Full Code Here

                        + ". Prefix: "
                        + namePrefix);
            }

            // PUT without a prefix
            return new ObjectId(objEntity.getName(), attribute.getName(), val);
        }

        // ... handle generic case - PK.size > 1

        Map<String, Object> idMap = new HashMap<String, Object>(pk.size() * 2);
        for (final DbAttribute attribute : pk) {

            String key = (prefix) ? namePrefix + attribute.getName() : attribute
                    .getName();

            Object val = dataRow.get(key);
            if (val == null) {
                throw new CayenneRuntimeException("Null value for '"
                        + key
                        + "'. Snapshot: "
                        + dataRow
                        + ". Prefix: "
                        + namePrefix);
            }

            // PUT without a prefix
            idMap.put(attribute.getName(), val);
        }

        return new ObjectId(objEntity.getName(), idMap);
    }
View Full Code Here

        if (!(object instanceof Persistent)) {
            throw new CayenneRuntimeException("Expected Persistent, got: " + object);
        }

        final Persistent source = (Persistent) object;
        ObjectId id = source.getObjectId();

        // sanity check
        if (id == null) {
            throw new CayenneRuntimeException("Server returned an object without an id: "
                    + source);
View Full Code Here

                        && relationshipQuery.getRelationship(
                                actingContext.getEntityResolver()).isToMany()) {
                    return !DONE;
                }

                ObjectId id = relationshipQuery.getObjectId();
                Object object = actingContext.getGraphManager().getNode(id);

                if (object != null) {

                    ClassDescriptor descriptor = actingContext
                            .getEntityResolver()
                            .getClassDescriptor(id.getEntityName());

                    if (!descriptor.isFault(object)) {

                        ArcProperty property = (ArcProperty) descriptor
                                .getProperty(relationshipQuery.getRelationshipName());
View Full Code Here

                            // subclass descriptors will be resolved on the fly... here
                            // find objects base descriptor.
                            ListIterator it = objects.listIterator();
                            while (it.hasNext()) {
                                Persistent object = (Persistent) it.next();
                                ObjectId id = object.getObjectId();

                                // sanity check
                                if (id == null) {
                                    throw new CayenneRuntimeException(
                                            "Server returned an object without an id: "
                                                    + object);
                                }

                                // have to resolve descriptor here for every object, as
                                // often a query will not have any info indicating the
                                // entity type
                                ClassDescriptor descriptor = resolver
                                        .getClassDescriptor(id.getEntityName());

                                it.set(merger.merge(object, descriptor));
                            }
                        }
                    }
View Full Code Here

        if (!(object instanceof Persistent)) {
            throw new CayenneRuntimeException("Expected Persistent, got: " + object);
        }

        final Persistent source = (Persistent) object;
        ObjectId id = source.getObjectId();

        // sanity check
        if (id == null) {
            throw new CayenneRuntimeException("Server returned an object without an id: "
                    + source);
        }

        Object seenTarget = seen.get(id);
        if (seenTarget != null) {
            return seenTarget;
        }

        descriptor = descriptor.getSubclassDescriptor(source.getClass());

        // presumably id's entity name should be of the right subclass.
        final ClassDescriptor targetDescriptor = targetResolver.getClassDescriptor(id
                .getEntityName());

        final Persistent target = (Persistent) targetDescriptor.createObject();
        target.setObjectId(id);
        seen.put(id, target);
View Full Code Here

                DataChannel.FLUSH_CASCADE_SYNC);

        assertEquals(0, serverContext.performQuery(query).size());

        // introduce changes
        clientServerChannel.onSync(serverContext, new NodeCreateOperation(new ObjectId(
                "MtTable1")), DataChannel.FLUSH_CASCADE_SYNC);

        assertEquals(1, serverContext.performQuery(query).size());
    }
View Full Code Here

        assertTrue(result instanceof ClientMtTable1);
        ClientMtTable1 clientObject = (ClientMtTable1) result;
        assertNotNull(clientObject.getObjectId());

        assertEquals(
                new ObjectId("MtTable1", MtTable1.TABLE1_ID_PK_COLUMN, 55),
                clientObject.getObjectId());
    }
View Full Code Here

        // make sure phantomly prefetched objects are not deallocated
        context.getObjectStore().objectMap = new HashMap<Object, Persistent>();

        // sanity check...
        DataObject g1 = (DataObject) context.getGraphManager().getNode(
                new ObjectId("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33001));
        assertNull(g1);

        List objects = context.performQuery(q);

        blockQueries();
        try {

            assertEquals(3, objects.size());

            Iterator it = objects.iterator();
            while (it.hasNext()) {
                Artist a = (Artist) it.next();
                ValueHolder list = (ValueHolder) a.getPaintingArray();

                assertNotNull(list);

                // intermediate relationship is not fetched...
                assertTrue(list.isFault());
            }

            // however both galleries must be in memory...
            g1 = (DataObject) context.getGraphManager().getNode(
                    new ObjectId("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33001));
            assertNotNull(g1);
            assertEquals(PersistenceState.COMMITTED, g1.getPersistenceState());
            DataObject g2 = (DataObject) context.getGraphManager().getNode(
                    new ObjectId("Gallery", Gallery.GALLERY_ID_PK_COLUMN, 33002));
            assertNotNull(g2);
            assertEquals(PersistenceState.COMMITTED, g2.getPersistenceState());
        }
        finally {
            unblockQueries();
View Full Code Here

TOP

Related Classes of org.apache.cayenne.ObjectId

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.