示例#1
0
 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();
 }