Class DbEntityManager
- java.lang.Object
-
- org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager
-
- All Implemented Interfaces:
EntityLoadListener
,Session
public class DbEntityManager extends java.lang.Object implements Session, EntityLoadListener
- Author:
- Daniel Meyer
-
-
Field Summary
Fields Modifier and Type Field Description static int
BATCH_SIZE
protected DbEntityCache
dbEntityCache
protected DbOperationManager
dbOperationManager
protected IdGenerator
idGenerator
protected boolean
isIgnoreForeignKeysForNextFlush
protected static EnginePersistenceLogger
LOG
protected java.util.List<OptimisticLockingListener>
optimisticLockingListeners
protected PersistenceSession
persistenceSession
protected static java.lang.String
TOGGLE_FOREIGN_KEY_STMT
-
Constructor Summary
Constructors Constructor Description DbEntityManager(IdGenerator idGenerator, PersistenceSession persistenceSession)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DbEntity
cacheFilter(DbEntity persistentObject)
returns the object in the cache.protected boolean
canIgnoreHistoryModificationFailure(DbOperation dbOperation)
Determines if a failed database operation (OptimisticLockingException) on a Historic entity can be ignored.void
close()
boolean
contains(DbEntity dbEntity)
CaseDefinitionQueryImpl
createCaseDefinitionQuery()
DeploymentQueryImpl
createDeploymentQuery()
ExecutionQueryImpl
createExecutionQuery()
GroupQueryImpl
createGroupQuery()
HistoricActivityInstanceQueryImpl
createHistoricActivityInstanceQuery()
HistoricDetailQueryImpl
createHistoricDetailQuery()
HistoricJobLogQueryImpl
createHistoricJobLogQuery()
HistoricProcessInstanceQueryImpl
createHistoricProcessInstanceQuery()
HistoricTaskInstanceQueryImpl
createHistoricTaskInstanceQuery()
HistoricVariableInstanceQueryImpl
createHistoricVariableInstanceQuery()
JobQueryImpl
createJobQuery()
ProcessDefinitionQueryImpl
createProcessDefinitionQuery()
ProcessInstanceQueryImpl
createProcessInstanceQuery()
TaskQueryImpl
createTaskQuery()
UserQueryImpl
createUserQuery()
void
delete(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
void
delete(DbEntity dbEntity)
DbBulkOperation
deletePreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
Several delete operations added by this method will be executed preserving the order of method calls, no matter what entity type they refer to.protected void
ensureHasId(DbEntity dbEntity)
protected java.util.List
filterLoadedObjects(java.util.List<java.lang.Object> loadedObjects)
void
flush()
protected void
flushCachedEntity(CachedDbEntity cachedDbEntity)
protected void
flushDbOperationManager()
protected void
flushDbOperations(java.util.List<DbOperation> operationsToFlush, java.util.List<DbOperation> allOperations)
void
flushEntity(DbEntity entity)
protected void
flushEntityCache()
Flushes the entity cache: Depending on the entity state, the requiredDbOperation
is performed and the cache is updated.void
forceUpdate(DbEntity entity)
<T extends DbEntity>
java.util.List<T>getCachedEntitiesByType(java.lang.Class<T> type)
<T extends DbEntity>
TgetCachedEntity(java.lang.Class<T> type, java.lang.String id)
DbEntityCache
getDbEntityCache()
DbOperationManager
getDbOperationManager()
java.util.List<java.lang.String>
getTableNamesPresentInDatabase()
protected void
handleConcurrentModification(DbOperation dbOperation)
Decides if an operation that failed for concurrent modifications can be tolerated, or ifOptimisticLockingException
should be raisedprotected void
handleConcurrentModificationCrdb(DbOperation dbOperation)
protected void
initializeEntityCache()
protected void
initializeOperationManager()
void
insert(DbEntity dbEntity)
boolean
isDeleted(DbEntity object)
boolean
isDirty(DbEntity dbEntity)
protected boolean
isHistoricByteArray(DbEntity dbEntity)
void
lock(java.lang.String statement)
void
lock(java.lang.String statement, java.lang.Object parameter)
void
merge(DbEntity dbEntity)
void
onEntityLoaded(DbEntity entity)
protected DbBulkOperation
performBulkOperation(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter, DbOperationType operationType)
protected DbBulkOperation
performBulkOperationPreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter, DbOperationType operationType)
protected void
performEntityOperation(CachedDbEntity cachedDbEntity, DbOperationType type)
<T extends DbEntity>
java.util.List<T>pruneDeletedEntities(java.util.List<T> listToPrune)
void
registerOptimisticLockingListener(OptimisticLockingListener optimisticLockingListener)
boolean
selectBoolean(java.lang.String statement, java.lang.Object parameter)
<T extends DbEntity>
TselectById(java.lang.Class<T> entityClass, java.lang.String id)
java.util.List
selectList(java.lang.String statement)
java.util.List
selectList(java.lang.String statement, java.lang.Object parameter)
java.util.List
selectList(java.lang.String statement, java.lang.Object parameter, int firstResult, int maxResults)
java.util.List
selectList(java.lang.String statement, java.lang.Object parameter, Page page)
java.util.List
selectList(java.lang.String statement, ListQueryParameterObject parameter)
java.util.List
selectList(java.lang.String statement, ListQueryParameterObject parameter, Page page)
java.util.List
selectListWithRawParameter(java.lang.String statement, java.lang.Object parameter, int firstResult, int maxResults)
java.lang.Object
selectOne(java.lang.String statement, java.lang.Object parameter)
void
setDbEntityCache(DbEntityCache dbEntityCache)
void
setDbOperationManager(DbOperationManager operationManager)
void
setIgnoreForeignKeysForNextFlush(boolean ignoreForeignKeysForNextFlush)
void
undoDelete(DbEntity entity)
void
update(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
void
updatePreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
Several update operations added by this method will be executed preserving the order of method calls, no matter what entity type they refer to.protected void
validateId(DbEntity dbEntity)
-
-
-
Field Detail
-
LOG
protected static final EnginePersistenceLogger LOG
-
TOGGLE_FOREIGN_KEY_STMT
protected static final java.lang.String TOGGLE_FOREIGN_KEY_STMT
- See Also:
- Constant Field Values
-
BATCH_SIZE
public static final int BATCH_SIZE
- See Also:
- Constant Field Values
-
optimisticLockingListeners
protected java.util.List<OptimisticLockingListener> optimisticLockingListeners
-
idGenerator
protected IdGenerator idGenerator
-
dbEntityCache
protected DbEntityCache dbEntityCache
-
dbOperationManager
protected DbOperationManager dbOperationManager
-
persistenceSession
protected PersistenceSession persistenceSession
-
isIgnoreForeignKeysForNextFlush
protected boolean isIgnoreForeignKeysForNextFlush
-
-
Constructor Detail
-
DbEntityManager
public DbEntityManager(IdGenerator idGenerator, PersistenceSession persistenceSession)
-
-
Method Detail
-
initializeOperationManager
protected void initializeOperationManager()
-
initializeEntityCache
protected void initializeEntityCache()
-
selectList
public java.util.List selectList(java.lang.String statement)
-
selectList
public java.util.List selectList(java.lang.String statement, java.lang.Object parameter)
-
selectList
public java.util.List selectList(java.lang.String statement, java.lang.Object parameter, Page page)
-
selectList
public java.util.List selectList(java.lang.String statement, ListQueryParameterObject parameter, Page page)
-
selectList
public java.util.List selectList(java.lang.String statement, java.lang.Object parameter, int firstResult, int maxResults)
-
selectList
public java.util.List selectList(java.lang.String statement, ListQueryParameterObject parameter)
-
selectListWithRawParameter
public java.util.List selectListWithRawParameter(java.lang.String statement, java.lang.Object parameter, int firstResult, int maxResults)
-
selectOne
public java.lang.Object selectOne(java.lang.String statement, java.lang.Object parameter)
-
selectBoolean
public boolean selectBoolean(java.lang.String statement, java.lang.Object parameter)
-
selectById
public <T extends DbEntity> T selectById(java.lang.Class<T> entityClass, java.lang.String id)
-
getCachedEntity
public <T extends DbEntity> T getCachedEntity(java.lang.Class<T> type, java.lang.String id)
-
getCachedEntitiesByType
public <T extends DbEntity> java.util.List<T> getCachedEntitiesByType(java.lang.Class<T> type)
-
filterLoadedObjects
protected java.util.List filterLoadedObjects(java.util.List<java.lang.Object> loadedObjects)
-
cacheFilter
protected DbEntity cacheFilter(DbEntity persistentObject)
returns the object in the cache. if this object was loaded before, then the original object is returned.
-
onEntityLoaded
public void onEntityLoaded(DbEntity entity)
- Specified by:
onEntityLoaded
in interfaceEntityLoadListener
-
lock
public void lock(java.lang.String statement)
-
lock
public void lock(java.lang.String statement, java.lang.Object parameter)
-
isDirty
public boolean isDirty(DbEntity dbEntity)
-
setIgnoreForeignKeysForNextFlush
public void setIgnoreForeignKeysForNextFlush(boolean ignoreForeignKeysForNextFlush)
-
flushDbOperationManager
protected void flushDbOperationManager()
-
flushDbOperations
protected void flushDbOperations(java.util.List<DbOperation> operationsToFlush, java.util.List<DbOperation> allOperations)
-
flushEntity
public void flushEntity(DbEntity entity)
-
handleConcurrentModification
protected void handleConcurrentModification(DbOperation dbOperation)
Decides if an operation that failed for concurrent modifications can be tolerated, or ifOptimisticLockingException
should be raised- Parameters:
dbOperation
-- Throws:
OptimisticLockingException
- if there is no handler for the failure
-
handleConcurrentModificationCrdb
protected void handleConcurrentModificationCrdb(DbOperation dbOperation)
-
canIgnoreHistoryModificationFailure
protected boolean canIgnoreHistoryModificationFailure(DbOperation dbOperation)
Determines if a failed database operation (OptimisticLockingException) on a Historic entity can be ignored.- Parameters:
dbOperation
- that failed- Returns:
- true if the failure can be ignored
-
isHistoricByteArray
protected boolean isHistoricByteArray(DbEntity dbEntity)
-
flushEntityCache
protected void flushEntityCache()
Flushes the entity cache: Depending on the entity state, the requiredDbOperation
is performed and the cache is updated.
-
flushCachedEntity
protected void flushCachedEntity(CachedDbEntity cachedDbEntity)
-
insert
public void insert(DbEntity dbEntity)
-
merge
public void merge(DbEntity dbEntity)
-
forceUpdate
public void forceUpdate(DbEntity entity)
-
delete
public void delete(DbEntity dbEntity)
-
undoDelete
public void undoDelete(DbEntity entity)
-
update
public void update(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
-
updatePreserveOrder
public void updatePreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
Several update operations added by this method will be executed preserving the order of method calls, no matter what entity type they refer to. They will though be executed after all "not-bulk" operations (e.g.insert(DbEntity)
ormerge(DbEntity)
) and after those updates added byupdate(Class, String, Object)
.- Parameters:
entityType
-statement
-parameter
-
-
delete
public void delete(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
-
deletePreserveOrder
public DbBulkOperation deletePreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter)
Several delete operations added by this method will be executed preserving the order of method calls, no matter what entity type they refer to. They will though be executed after all "not-bulk" operations (e.g.insert(DbEntity)
ormerge(DbEntity)
) and after those deletes added bydelete(Class, String, Object)
.- Parameters:
entityType
-statement
-parameter
-- Returns:
- delete operation
-
performBulkOperation
protected DbBulkOperation performBulkOperation(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter, DbOperationType operationType)
-
performBulkOperationPreserveOrder
protected DbBulkOperation performBulkOperationPreserveOrder(java.lang.Class<? extends DbEntity> entityType, java.lang.String statement, java.lang.Object parameter, DbOperationType operationType)
-
performEntityOperation
protected void performEntityOperation(CachedDbEntity cachedDbEntity, DbOperationType type)
-
isDeleted
public boolean isDeleted(DbEntity object)
-
ensureHasId
protected void ensureHasId(DbEntity dbEntity)
-
validateId
protected void validateId(DbEntity dbEntity)
-
pruneDeletedEntities
public <T extends DbEntity> java.util.List<T> pruneDeletedEntities(java.util.List<T> listToPrune)
-
contains
public boolean contains(DbEntity dbEntity)
-
getDbOperationManager
public DbOperationManager getDbOperationManager()
-
setDbOperationManager
public void setDbOperationManager(DbOperationManager operationManager)
-
getDbEntityCache
public DbEntityCache getDbEntityCache()
-
setDbEntityCache
public void setDbEntityCache(DbEntityCache dbEntityCache)
-
createDeploymentQuery
public DeploymentQueryImpl createDeploymentQuery()
-
createProcessDefinitionQuery
public ProcessDefinitionQueryImpl createProcessDefinitionQuery()
-
createCaseDefinitionQuery
public CaseDefinitionQueryImpl createCaseDefinitionQuery()
-
createProcessInstanceQuery
public ProcessInstanceQueryImpl createProcessInstanceQuery()
-
createExecutionQuery
public ExecutionQueryImpl createExecutionQuery()
-
createTaskQuery
public TaskQueryImpl createTaskQuery()
-
createJobQuery
public JobQueryImpl createJobQuery()
-
createHistoricProcessInstanceQuery
public HistoricProcessInstanceQueryImpl createHistoricProcessInstanceQuery()
-
createHistoricActivityInstanceQuery
public HistoricActivityInstanceQueryImpl createHistoricActivityInstanceQuery()
-
createHistoricTaskInstanceQuery
public HistoricTaskInstanceQueryImpl createHistoricTaskInstanceQuery()
-
createHistoricDetailQuery
public HistoricDetailQueryImpl createHistoricDetailQuery()
-
createHistoricVariableInstanceQuery
public HistoricVariableInstanceQueryImpl createHistoricVariableInstanceQuery()
-
createHistoricJobLogQuery
public HistoricJobLogQueryImpl createHistoricJobLogQuery()
-
createUserQuery
public UserQueryImpl createUserQuery()
-
createGroupQuery
public GroupQueryImpl createGroupQuery()
-
registerOptimisticLockingListener
public void registerOptimisticLockingListener(OptimisticLockingListener optimisticLockingListener)
-
getTableNamesPresentInDatabase
public java.util.List<java.lang.String> getTableNamesPresentInDatabase()
-
-