/// <summary> /// Used to check if object must be reconnected to current session /// <pre> /// An object must be reconnected to session if OdbConfiguration.reconnectObjectsToSession() is true /// and object is not in local cache and is in cross session cache. /// </summary> /// <remarks> /// Used to check if object must be reconnected to current session /// <pre> /// An object must be reconnected to session if OdbConfiguration.reconnectObjectsToSession() is true /// and object is not in local cache and is in cross session cache. In this case /// we had it to local cache /// </pre> /// </remarks> /// <param name="@object"></param> private void CheckIfObjectMustBeReconnected(object @object) { if (engine == null) { // This protection is for JUnit return; } NeoDatis.Odb.Core.Transaction.ISession session = engine.GetSession(true); // If object is in local cache, no need to reconnect it if (session.GetCache().ExistObject(@object)) { return; } NeoDatis.Odb.OID oidCrossSession = crossSessionCache.GetOid(@object); if (oidCrossSession != null) { // reconnect object NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = engine.GetObjectInfoHeaderFromOid (oidCrossSession); session.AddObjectToCache(oidCrossSession, @object, oih); } }
public virtual void Commit() { if (NeoDatis.Odb.OdbConfiguration.IsDebugEnabled(LogId)) { NeoDatis.Tool.DLogger.Info("Commiting " + numberOfWriteActions + " write actions - In Memory : " + hasAllWriteActionsInMemory + " - sid=" + session.GetId()); } // Check if database has been rollbacked CheckRollback(); // call the commit listeners ManageCommitListenersBefore(); if (currentWriteAction != null && !currentWriteAction.IsEmpty()) { AddWriteAction(currentWriteAction); currentWriteAction = null; } if (fsi == null && numberOfWriteActions != 0) { throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.TransactionAlreadyCommitedOrRollbacked ); } if (numberOfWriteActions == 0 || readOnlyMode) { // FIXME call commitMetaModel in realOnlyMode? CommitMetaModel(); // Nothing to do if (fsi != null) { fsi.Close(); fsi = null; } if (session != null) { session.GetCache().ClearOnCommit(); } return; } // Marks the transaction as committed SetCommited(true); // Apply the write actions the main database file ApplyTo(); // Commit Meta Model changes CommitMetaModel(); if (archiveLog) { fsi.SetWritePositionNoVerification(0, false); fsi.WriteByte((byte)2, false); fsi.GetIo().EnableAutomaticDelete(false); fsi.Close(); fsi = null; } else { fsi.Close(); Delete(); fsi = null; } if (session != null) { session.GetCache().ClearOnCommit(); } ManageCommitListenersAfter(); }