use of org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation in project camunda-bpm-platform by camunda.
the class ViolateIntegrityConstraintDelegate method execute.
public void execute(DelegateExecution execution) throws Exception {
String existingId = execution.getId();
// insert an execution referencing the current execution
ExecutionEntity newExecution = new ExecutionEntity();
newExecution.setId("someId");
newExecution.setParentId(existingId);
DbEntityOperation insertOperation = new DbEntityOperation();
insertOperation.setOperationType(DbOperationType.INSERT);
insertOperation.setEntity(newExecution);
Context.getCommandContext().getDbSqlSession().executeDbOperation(insertOperation);
}
use of org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation in project camunda-bpm-platform by camunda.
the class DbEntityManager method performEntityOperation.
protected void performEntityOperation(CachedDbEntity cachedDbEntity, DbOperationType type) {
DbEntityOperation dbOperation = new DbEntityOperation();
dbOperation.setEntity(cachedDbEntity.getEntity());
dbOperation.setFlushRelevantEntityReferences(cachedDbEntity.getFlushRelevantEntityReferences());
dbOperation.setOperationType(type);
dbOperationManager.addOperation(dbOperation);
}
use of org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation in project camunda-bpm-platform by camunda.
the class DbEntityManager method checkFlushResults.
protected void checkFlushResults(List<DbOperation> operationsToFlush, List<BatchResult> flushResult) {
int flushResultSize = 0;
if (flushResult != null && flushResult.size() > 0) {
LOG.printBatchResults(flushResult);
// process the batch results to handle Optimistic Lock Exceptions
Iterator<DbOperation> operationIt = operationsToFlush.iterator();
for (BatchResult batchResult : flushResult) {
for (int statementResult : batchResult.getUpdateCounts()) {
flushResultSize++;
DbOperation thisOperation = operationIt.next();
if (thisOperation instanceof DbEntityOperation && ((DbEntityOperation) thisOperation).getEntity() instanceof HasDbRevision && !thisOperation.getOperationType().equals(DbOperationType.INSERT)) {
final DbEntity dbEntity = ((DbEntityOperation) thisOperation).getEntity();
if (statementResult != 1) {
((DbEntityOperation) thisOperation).setFailed(true);
handleOptimisticLockingException(thisOperation);
} else {
// update revision number in cache
if (thisOperation.getOperationType().equals(DbOperationType.UPDATE)) {
HasDbRevision versionedObject = (HasDbRevision) dbEntity;
versionedObject.setRevision(versionedObject.getRevisionNext());
}
}
}
}
}
// this must not happen, but worth checking
if (operationsToFlush.size() != flushResultSize) {
LOG.wrongBatchResultsSizeException(operationsToFlush);
}
}
}
Aggregations