Examples of Persistent


Examples of org.apache.cayenne.Persistent

        // have to synchronize almost the entire method to prevent multiple threads from
        // messing up dataobjects per CAY-845. Originally only parts of "else" were
        // synchronized, but we had to expand the lock scope to ensure consistent
        // behavior.
        synchronized (getGraphManager()) {
            Persistent cachedObject = (Persistent) getGraphManager().getNode(id);

            // merge into an existing object
            if (cachedObject != null) {

                int state = cachedObject.getPersistenceState();

                // TODO: Andrus, 1/24/2006 implement smart merge for modified objects...
                if (cachedObject != prototype
                        && state != PersistenceState.MODIFIED
                        && state != PersistenceState.DELETED) {

                    descriptor.injectValueHolders(cachedObject);

                    if (prototype != null
                            && ((Persistent) prototype).getPersistenceState() != PersistenceState.HOLLOW) {

                        descriptor.shallowMerge(prototype, cachedObject);

                        if (state == PersistenceState.HOLLOW) {
                            cachedObject.setPersistenceState(PersistenceState.COMMITTED);
                        }
                    }
                }

                return cachedObject;
            }
            // create and merge into a new object
            else {

                Persistent localObject;

                localObject = (Persistent) descriptor.createObject();

                localObject.setObjectContext(this);
                localObject.setObjectId(id);

                getGraphManager().registerNode(id, localObject);

                if (prototype != null
                        && ((Persistent) prototype).getPersistenceState() != PersistenceState.HOLLOW) {
                    localObject.setPersistenceState(PersistenceState.COMMITTED);
                    descriptor.injectValueHolders(localObject);
                    descriptor.shallowMerge(prototype, localObject);
                }
                else {
                    localObject.setPersistenceState(PersistenceState.HOLLOW);
                }

                return localObject;
            }
        }
View Full Code Here

Examples of org.apache.cayenne.Persistent

                    .getClientEntityResolver());
            Iterator it = serverObjects.iterator();
            PrefetchTreeNode prefetchTree = serverMetadata.getPrefetchTree();

            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);
View Full Code Here

Examples of org.apache.cayenne.Persistent

        Iterator it = rows.iterator();

        while (it.hasNext()) {

            DataRow row = (DataRow) it.next();
            Persistent object = objectFromDataRow(row);
            results.add(object);

            // 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) {
                node.linkToParent(object, parentObject);
            }
        }

        // now deal with snapshots
View Full Code Here

Examples of org.apache.cayenne.Persistent

        // 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
        int state = object.getPersistenceState();
        switch (state) {
            case PersistenceState.COMMITTED:
            case PersistenceState.MODIFIED:
            case PersistenceState.DELETED:
                // process the above only if refresh is requested...
View Full Code Here

Examples of org.apache.cayenne.Persistent

    public Object merge(Object object, ClassDescriptor descriptor) {
        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;
        }

        final Persistent target = context.localObject(id, source);
        seen.put(id, target);

        descriptor = descriptor.getSubclassDescriptor(source.getClass());
        descriptor.visitProperties(new PropertyVisitor() {
View Full Code Here

Examples of org.apache.cayenne.Persistent

        boolean incorrectObjectType(Object object) {
            if (!(object instanceof Persistent)) {
                return true;
            }

            Persistent persistent = (Persistent) object;
            if (persistent.getObjectContext() != context) {
                return true;
            }

            return false;
        }
View Full Code Here

Examples of org.apache.gora.persistency.Persistent

              put(i, new ListGenericArray(fields.get(i).schema()));
            }
          }
          break;
        case RECORD :
          Persistent field = ((Persistent)get(i));
          if(field != null) field.clear();
          break;
        case BOOLEAN: put(i, false); break;
        case INT    : put(i, 0); break;
        case DOUBLE : put(i, 0d); break;
        case FLOAT  : put(i, 0f); break;
View Full Code Here

Examples of org.apache.torque.om.Persistent

     *
     */

    public static Persistent newPersistentInstance()
    {
        Persistent obj = null;

        if(permissionObject == null)
        {
            // This can happen if the Turbine wants to determine the
            // name of the anonymous user before the security service
View Full Code Here

Examples of org.apache.torque.om.Persistent

     *
     */

    public static Persistent newPersistentInstance()
    {
        Persistent obj = null;

        if (userObject == null)
        {
            // This can happen if the Turbine wants to determine the
            // name of the anonymous user before the security service
View Full Code Here

Examples of org.apache.torque.om.Persistent

     *
     */

    public static Persistent newPersistentInstance()
    {
        Persistent obj = null;

        if (roleObject == null)
        {
            // This can happen if the Turbine wants to determine the
            // name of the anonymous user before the security service
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.