Beispiel #1
0
        protected internal virtual void executeInsertEntity(string insertStatement, object parameter)
        {
            LOG.executeDatabaseOperation("INSERT", parameter);
            sqlSession.insert(insertStatement, parameter);

            // set revision of our copy to 1
            if (parameter is HasDbRevision)
            {
                HasDbRevision versionedObject = (HasDbRevision)parameter;
                versionedObject.Revision = 1;
            }
        }
Beispiel #2
0
        protected internal virtual void checkFlushResults(IList <DbOperation> operationsToFlush, IList <BatchResult> flushResult)
        {
            int flushResultSize = 0;

            if (flushResult != null && flushResult.Count > 0)
            {
                LOG.printBatchResults(flushResult);
                //process the batch results to handle Optimistic Lock Exceptions
                IEnumerator <DbOperation> operationIt = operationsToFlush.GetEnumerator();
                foreach (BatchResult batchResult in flushResult)
                {
                    foreach (int statementResult in batchResult.UpdateCounts)
                    {
                        flushResultSize++;
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        DbOperation thisOperation = operationIt.next();
                        thisOperation.RowsAffected = statementResult;
                        if (thisOperation is DbEntityOperation && ((DbEntityOperation)thisOperation).Entity is HasDbRevision && !thisOperation.OperationType.Equals(DbOperationType.INSERT))
                        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.DbEntity dbEntity = ((org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation) thisOperation).getEntity();
                            DbEntity dbEntity = ((DbEntityOperation)thisOperation).Entity;
                            if (statementResult != 1)
                            {
                                ((DbEntityOperation)thisOperation).Failed = true;
                                handleOptimisticLockingException(thisOperation);
                            }
                            else
                            {
                                //update revision number in cache
                                if (thisOperation.OperationType.Equals(DbOperationType.UPDATE))
                                {
                                    HasDbRevision versionedObject = (HasDbRevision)dbEntity;
                                    versionedObject.Revision = versionedObject.RevisionNext;
                                }
                            }
                        }
                    }
                }
                //this must not happen, but worth checking
                if (operationsToFlush.Count != flushResultSize)
                {
                    LOG.wrongBatchResultsSizeException(operationsToFlush);
                }
            }
        }
Beispiel #3
0
        // update ////////////////////////////////////////

        protected internal override void updateEntity(DbEntityOperation operation)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.db.DbEntity dbEntity = operation.getEntity();
            DbEntity dbEntity = operation.Entity;

            string updateStatement = dbSqlSessionFactory.getUpdateStatement(dbEntity);

            ensureNotNull("no update statement for " + dbEntity.GetType() + " in the ibatis mapping files", "updateStatement", updateStatement);

            LOG.executeDatabaseOperation("UPDATE", dbEntity);

            if (Context.ProcessEngineConfiguration.JdbcBatchProcessing)
            {
                // execute update
                executeUpdate(updateStatement, dbEntity);
            }
            else
            {
                // execute update
                int numOfRowsUpdated = executeUpdate(updateStatement, dbEntity);

                if (dbEntity is HasDbRevision)
                {
                    if (numOfRowsUpdated != 1)
                    {
                        // failed with optimistic locking
                        operation.Failed = true;
                        return;
                    }
                    else
                    {
                        // increment revision of our copy
                        HasDbRevision versionedObject = (HasDbRevision)dbEntity;
                        versionedObject.Revision = versionedObject.RevisionNext;
                    }
                }
            }

            // perform post update action
            entityUpdated(dbEntity);
        }