Search in sources :

Example 11 with DbEntity

use of org.camunda.bpm.engine.impl.db.DbEntity in project camunda-bpm-platform by camunda.

the class DbEntityManager method filterLoadedObjects.

protected List filterLoadedObjects(List<Object> loadedObjects) {
    if (loadedObjects.isEmpty() || loadedObjects.get(0) == null) {
        return loadedObjects;
    }
    if (!(DbEntity.class.isAssignableFrom(loadedObjects.get(0).getClass()))) {
        return loadedObjects;
    }
    List<DbEntity> filteredObjects = new ArrayList<DbEntity>(loadedObjects.size());
    for (Object loadedObject : loadedObjects) {
        DbEntity cachedPersistentObject = cacheFilter((DbEntity) loadedObject);
        filteredObjects.add(cachedPersistentObject);
    }
    return filteredObjects;
}
Also used : DbEntity(org.camunda.bpm.engine.impl.db.DbEntity) CachedDbEntity(org.camunda.bpm.engine.impl.db.entitymanager.cache.CachedDbEntity) ArrayList(java.util.ArrayList) ListQueryParameterObject(org.camunda.bpm.engine.impl.db.ListQueryParameterObject)

Example 12 with DbEntity

use of org.camunda.bpm.engine.impl.db.DbEntity 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);
        }
    }
}
Also used : DbOperation(org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation) DbEntityOperation(org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation) DbEntity(org.camunda.bpm.engine.impl.db.DbEntity) CachedDbEntity(org.camunda.bpm.engine.impl.db.entitymanager.cache.CachedDbEntity) HasDbRevision(org.camunda.bpm.engine.impl.db.HasDbRevision) BatchResult(org.apache.ibatis.executor.BatchResult)

Aggregations

DbEntity (org.camunda.bpm.engine.impl.db.DbEntity)12 CachedDbEntity (org.camunda.bpm.engine.impl.db.entitymanager.cache.CachedDbEntity)4 HasDbRevision (org.camunda.bpm.engine.impl.db.HasDbRevision)3 ArrayList (java.util.ArrayList)2 ListQueryParameterObject (org.camunda.bpm.engine.impl.db.ListQueryParameterObject)2 HashMap (java.util.HashMap)1 List (java.util.List)1 BatchResult (org.apache.ibatis.executor.BatchResult)1 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)1 DbEntityLifecycleAware (org.camunda.bpm.engine.impl.db.DbEntityLifecycleAware)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 DELETED_PERSISTENT (org.camunda.bpm.engine.impl.db.entitymanager.cache.DbEntityState.DELETED_PERSISTENT)1 DELETED_TRANSIENT (org.camunda.bpm.engine.impl.db.entitymanager.cache.DbEntityState.DELETED_TRANSIENT)1 PERSISTENT (org.camunda.bpm.engine.impl.db.entitymanager.cache.DbEntityState.PERSISTENT)1 TRANSIENT (org.camunda.bpm.engine.impl.db.entitymanager.cache.DbEntityState.TRANSIENT)1 DbBulkOperation (org.camunda.bpm.engine.impl.db.entitymanager.operation.DbBulkOperation)1 DbEntityOperation (org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation)1 DbOperation (org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1