Class DbSqlSession
- All Implemented Interfaces:
Session
- Direct Known Subclasses:
ProfilingDbSqlSession
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final List<ActivitiVersion>protected Map<Class<? extends Entity>,List<BulkDeleteOperation>> protected Stringprotected Stringprotected DbSqlSessionFactoryprotected EntityCachestatic String[]protected static final Stringprotected static final Stringprotected org.apache.ibatis.session.SqlSession -
Constructor Summary
ConstructorsConstructorDescriptionDbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache) DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache, Connection connection, String catalog, String schema) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringaddMissingComponent(String missingComponents, String component) protected StringaddSqlStatementPiece(String sqlStatement, String line) protected ListcacheLoadOrStore(List<Object> loadedObjects) protected EntitycacheLoadOrStore(Entity entity) Returns the object in the cache.voidclose()protected voidcollectChildExecutionsForInsertion(List<Entity> result, Map<String, List<ExecutionEntity>> parentToChildrenMapping, Set<String> handledExecutionIds, String parentId, boolean parentBeforeChildExecution) voidcommit()voidvoidprotected voidprotected voidvoidvoidprotected voiddbSchemaUpgrade(String component, int currentDatabaseVersionsIndex) protected voidvoidExecutes aBulkDeleteOperation, with the sql in the statement parameter.voidvoidvoidexecuteMandatorySchemaResource(String operation, String component) voidexecuteSchemaResource(String operation, String component, String resourceName, boolean isOptional) protected intfindMatchingVersionIndex(String dbVersion) Returns the index in the list ofACTIVITI_VERSIONSmatching the provided string version.voidflush()protected voidflushBulkDeletes(Class<? extends Entity> entityClass) protected voidflushBulkInsert(Collection<Entity> entities, Class<? extends Entity> clazz) protected voidflushDeleteEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToDelete) protected voidprotected voidflushInsertEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToInsert) protected voidprotected voidflushRegularInsert(Entity entity, Class<? extends Entity> clazz) protected void<T> TgetCustomMapper(Class<T> type) protected StringgetResourceForDbOperation(String directory, String operation, String component) org.apache.ibatis.session.SqlSessionprotected voidincrementRevision(Entity insertedObject) voidbooleanbooleanisEntityInserted(Entity entity) booleanisEntityToBeDeleted(Entity entity) booleanbooleanprotected booleanbooleanisMysql()booleanisOracle()booleanisTablePresent(String tableName) protected Collection<Entity>orderExecutionEntities(Map<String, Entity> executionEntities, boolean parentBeforeChildExecution) voidvoidprotected StringprependDatabaseTablePrefix(String tableName) protected StringreadNextTrimmedLine(BufferedReader reader) protected voidClears all deleted and inserted objects from the cache, and removes inserts and deletes that cancel each other.voidrollback()<T extends Entity>
TselectById(Class<T> entityClass, String id) <T extends Entity>
TselectById(Class<T> entityClass, String id, boolean useCache) selectList(String statement) selectList(String statement, Object parameter) selectList(String statement, Object parameter, boolean useCache) selectList(String statement, Object parameter, int firstResult, int maxResults) selectList(String statement, Object parameter, int firstResult, int maxResults, boolean useCache) selectList(String statement, Object parameter, Page page) selectList(String statement, Object parameter, Page page, boolean useCache) selectList(String statement, ListQueryParameterObject parameter) selectList(String statement, ListQueryParameterObject parameter, boolean useCache) selectList(String statement, ListQueryParameterObject parameter, Page page) selectList(String statement, ListQueryParameterObject parameter, Page page, boolean useCache) selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults) selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults, boolean useCache) selectListWithRawParameterWithoutFilter(String statement, Object parameter, int firstResult, int maxResults) intvoidprotected StringupdateDdlForMySqlVersionLowerThan56(String ddlStatements) MySQL is funny when it comes to timestamps and dates.
-
Field Details
-
LAST_V5_VERSION
- See Also:
-
LAST_V7_VERSION
- See Also:
-
ACTIVITI_VERSIONS
-
sqlSession
protected org.apache.ibatis.session.SqlSession sqlSession -
dbSqlSessionFactory
-
entityCache
-
insertedObjects
-
deletedObjects
-
bulkDeleteOperations
-
updatedObjects
-
connectionMetadataDefaultCatalog
-
connectionMetadataDefaultSchema
-
JDBC_METADATA_TABLE_TYPES
-
-
Constructor Details
-
DbSqlSession
-
DbSqlSession
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache, Connection connection, String catalog, String schema)
-
-
Method Details
-
insert
-
update
-
update
-
delete
Executes aBulkDeleteOperation, with the sql in the statement parameter. The passed class determines when this operation will be executed: it will be executed when the particular class has passed in theEntityDependencyOrder. -
delete
-
selectList
-
selectList
-
selectList
-
selectList
-
selectList
-
selectList
-
selectList
public List selectList(String statement, ListQueryParameterObject parameter, Page page, boolean useCache) -
selectList
-
selectList
-
selectList
-
selectList
-
selectListWithRawParameter
-
selectListWithRawParameter
-
selectListWithRawParameterWithoutFilter
-
selectOne
-
selectById
-
selectById
-
cacheLoadOrStore
-
cacheLoadOrStore
Returns the object in the cache. If this object was loaded before, then the original object is returned (the cached version is more recent). If this is the first time this object is loaded, then the loadedObject is added to the cache. -
flush
public void flush() -
removeUnnecessaryOperations
protected void removeUnnecessaryOperations()Clears all deleted and inserted objects from the cache, and removes inserts and deletes that cancel each other.Also removes deletes with duplicate ids.
-
determineUpdatedObjects
public void determineUpdatedObjects() -
debugFlush
protected void debugFlush() -
isEntityInserted
-
isEntityToBeDeleted
-
flushInserts
protected void flushInserts() -
flushInsertEntities
protected void flushInsertEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToInsert) -
orderExecutionEntities
protected Collection<Entity> orderExecutionEntities(Map<String, Entity> executionEntities, boolean parentBeforeChildExecution) -
collectChildExecutionsForInsertion
-
flushRegularInsert
-
flushBulkInsert
-
incrementRevision
-
flushUpdates
protected void flushUpdates() -
flushDeletes
protected void flushDeletes() -
flushBulkDeletes
-
flushDeleteEntities
protected void flushDeleteEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToDelete) -
close
public void close() -
commit
public void commit() -
rollback
public void rollback() -
dbSchemaCheckVersion
public void dbSchemaCheckVersion() -
addMissingComponent
-
getDbVersion
-
dbSchemaCreate
public void dbSchemaCreate() -
dbSchemaCreateHistory
protected void dbSchemaCreateHistory() -
dbSchemaCreateEngine
protected void dbSchemaCreateEngine() -
dbSchemaDrop
public void dbSchemaDrop() -
dbSchemaPrune
public void dbSchemaPrune() -
executeMandatorySchemaResource
-
dbSchemaUpdate
-
findMatchingVersionIndex
Returns the index in the list ofACTIVITI_VERSIONSmatching the provided string version. Returns -1 if no match can be found. -
isEngineTablePresent
public boolean isEngineTablePresent() -
isHistoryTablePresent
public boolean isHistoryTablePresent() -
isTablePresent
-
prependDatabaseTablePrefix
-
dbSchemaUpgrade
-
getResourceForDbOperation
-
executeSchemaResource
-
updateDdlForMySqlVersionLowerThan56
MySQL is funny when it comes to timestamps and dates.More specifically, for a DDL statement like 'MYCOLUMN timestamp(3)': - MySQL 5.6.4+ has support for timestamps/dates with millisecond (or smaller) precision. The DDL above works and the data in the table will have millisecond precision - MySQL < 5.5.3 allows the DDL statement, but ignores it. The DDL above works but the data won't have millisecond precision - MySQL 5.5.3 < [version] < 5.6.4 gives and exception when using the DDL above.
Also, the 5.5 and 5.6 branches of MySQL are both actively developed and patched.
Hence, when doing auto-upgrade/creation of the Activiti tables, the default MySQL DDL file is used and all timestamps/datetimes are converted to not use the millisecond precision by string replacement done in the method below.
If using the DDL files directly (which is a sane choice in production env.), there is a distinction between MySQL version < 5.6.
-
addSqlStatementPiece
-
readNextTrimmedLine
- Throws:
IOException
-
isMissingTablesException
-
performSchemaOperationsProcessEngineBuild
public void performSchemaOperationsProcessEngineBuild() -
performSchemaOperationsProcessEngineClose
public void performSchemaOperationsProcessEngineClose() -
getCustomMapper
-
isMysql
public boolean isMysql() -
isMariaDb
public boolean isMariaDb() -
isOracle
public boolean isOracle() -
createDeploymentQuery
-
createModelQueryImpl
-
createProcessDefinitionQuery
-
createProcessInstanceQuery
-
createExecutionQuery
-
createTaskQuery
-
createJobQuery
-
createHistoricProcessInstanceQuery
-
createHistoricActivityInstanceQuery
-
createHistoricTaskInstanceQuery
-
createHistoricDetailQuery
-
createHistoricVariableInstanceQuery
-
getSqlSession
public org.apache.ibatis.session.SqlSession getSqlSession() -
getDbSqlSessionFactory
-