Example #1
0
        /// <summary>This method is used to make sure that client oids and server oids are equal.
        ///     </summary>
        /// <remarks>
        /// This method is used to make sure that client oids and server oids are equal.
        /// <pre>
        /// When storing an object, the client side does nt know the oid that each object will receive. So the client create
        /// temporary (sequencial) oids. These oids are sent to the server in the object meta-representations. On the server side,
        /// real OIDs are created and associated to the objects and to the client side ids. After calling the store on the server side
        /// The client use the the synchronizeIds method to replace client ids by the right server side ids.
        /// </pre>
        /// </remarks>
        public virtual void SynchronizeIds(NeoDatis.Odb.OID[] clientIds, NeoDatis.Odb.OID
                                           [] serverIds)
        {
            if (clientIds.Length != clientOids.Count)
            {
                throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ClientServerSynchronizeIds
                                                           .AddParameter(clientOids.Count).AddParameter(clientIds.Length));
            }
            NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = null;
            NeoDatis.Odb.Core.Transaction.ICache cache = GetSession().GetCache();
            object @object = null;

            NeoDatis.Odb.OID id = null;
            NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                                                 .GetCrossSessionCache(storageEngine.GetBaseIdentification().GetIdentification());
            for (int i = 0; i < clientIds.Length; i++)
            {
                id      = clientIds[i];
                cnnoi   = aois[id];
                @object = objects[id];
                // Server ids may be null when an object or part of an object has been updated.
                // In these case local objects have already the correct ids
                if (serverIds[i] != null)
                {
                    cnnoi.SetOid(serverIds[i]);
                    cache.AddObject(serverIds[i], @object, cnnoi.GetHeader());
                }
                // As serverIds may be null, we need to check it
                if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && serverIds[i] !=
                    null)
                {
                    crossSessionCache.AddObject(@object, serverIds[i]);
                }
            }
        }
Example #2
0
 public virtual void AddObjectToCache(NeoDatis.Odb.OID oid, object @object, NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader
                                      oih)
 {
     if (@object == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.CacheNullObject
                                                    .AddParameter(@object));
     }
     if (oid == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.CacheNullOid
                                                    .AddParameter(oid));
     }
     if (oih == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.CacheNullObject
                                                    .AddParameter(oih));
     }
     cache.AddObject(oid, @object, oih);
 }