Exemplo n.º 1
0
        protected internal virtual void flushDbOperationManager()
        {
            // obtain totally ordered operation list from operation manager
            IList <DbOperation> operationsToFlush = dbOperationManager.calculateFlush();

            if (operationsToFlush == null || operationsToFlush.Count == 0)
            {
                return;
            }

            LOG.databaseFlushSummary(operationsToFlush);

            // If we want to delete all table data as bulk operation, on tables which have self references,
            // We need to turn the foreign key check off on MySQL and MariaDB.
            // On other databases we have to do nothing, the mapped statement will be empty.
            if (isIgnoreForeignKeysForNextFlush)
            {
                persistenceSession.executeNonEmptyUpdateStmt(TOGGLE_FOREIGN_KEY_STMT, false);
                persistenceSession.flushOperations();
            }

            try
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<java.util.List<org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation>> batches = org.camunda.bpm.engine.impl.util.CollectionUtil.partition(operationsToFlush, BATCH_SIZE);
                IList <IList <DbOperation> > batches = CollectionUtil.partition(operationsToFlush, BATCH_SIZE);
                foreach (IList <DbOperation> batch in batches)
                {
                    flushDbOperations(batch, operationsToFlush);
                }
            }
            finally
            {
                if (isIgnoreForeignKeysForNextFlush)
                {
                    persistenceSession.executeNonEmptyUpdateStmt(TOGGLE_FOREIGN_KEY_STMT, true);
                    persistenceSession.flushOperations();
                    isIgnoreForeignKeysForNextFlush = false;
                }
            }
        }