protected internal virtual void performEntityOperation(CachedDbEntity cachedDbEntity, DbOperationType type) { DbEntityOperation dbOperation = new DbEntityOperation(); dbOperation.Entity = cachedDbEntity.Entity; dbOperation.FlushRelevantEntityReferences = cachedDbEntity.FlushRelevantEntityReferences; dbOperation.OperationType = type; dbOperationManager.addOperation(dbOperation); }
public virtual void forceUpdate(DbEntity entity) { CachedDbEntity cachedEntity = dbEntityCache.getCachedEntity(entity); if (cachedEntity != null && cachedEntity.EntityState == PERSISTENT) { cachedEntity.forceSetDirty(); } }
public virtual void flushEntity(DbEntity entity) { CachedDbEntity cachedEntity = dbEntityCache.getCachedEntity(entity); if (cachedEntity != null) { flushCachedEntity(cachedEntity); } flushDbOperationManager(); }
public virtual bool isDirty(DbEntity dbEntity) { CachedDbEntity cachedEntity = dbEntityCache.getCachedEntity(dbEntity); if (cachedEntity == null) { return(false); } else { return(cachedEntity.Dirty || cachedEntity.EntityState == DbEntityState.MERGED); } }
protected internal virtual void flushCachedEntity(CachedDbEntity cachedDbEntity) { if (cachedDbEntity.EntityState == TRANSIENT) { // latest state of references in cache is relevant when determining insertion order cachedDbEntity.determineEntityReferences(); // perform INSERT performEntityOperation(cachedDbEntity, INSERT); // mark PERSISTENT cachedDbEntity.EntityState = PERSISTENT; } else if (cachedDbEntity.EntityState == PERSISTENT && cachedDbEntity.Dirty) { // object is dirty -> perform UPDATE performEntityOperation(cachedDbEntity, UPDATE); } else if (cachedDbEntity.EntityState == MERGED) { // perform UPDATE performEntityOperation(cachedDbEntity, UPDATE); // mark PERSISTENT cachedDbEntity.EntityState = PERSISTENT; } else if (cachedDbEntity.EntityState == DELETED_TRANSIENT) { // remove from cache dbEntityCache.remove(cachedDbEntity); } else if (cachedDbEntity.EntityState == DELETED_PERSISTENT || cachedDbEntity.EntityState == DELETED_MERGED) { // perform DELETE performEntityOperation(cachedDbEntity, DELETE); // remove from cache dbEntityCache.remove(cachedDbEntity); } // if object is PERSISTENT after flush if (cachedDbEntity.EntityState == PERSISTENT) { // make a new copy cachedDbEntity.makeCopy(); // update cached references cachedDbEntity.determineEntityReferences(); } }
public override Void execute(CommandContext commandContext) { ExecutionEntity execution = commandContext.ExecutionManager.findExecutionById(executionId); // fetch the variable instance but not the value (make sure the byte array is lazily fetched) VariableInstanceEntity varInstance = (VariableInstanceEntity)execution.getVariableInstanceLocal(varName); string byteArrayValueId = varInstance.ByteArrayValueId; assertNotNull("Byte array id is expected to be not null", byteArrayValueId); CachedDbEntity cachedByteArray = commandContext.DbEntityManager.DbEntityCache.getCachedEntity(typeof(ByteArrayEntity), byteArrayValueId); assertNull("Byte array is expected to be not fetched yet / lazily fetched.", cachedByteArray); monitor.sync(); // now update the value execution.setVariableLocal(varInstance.Name, newValue); return(null); }