public class DbSqlSession extends Object implements Session
| Modifier and Type | Field and Description |
|---|---|
protected static List<ActivitiVersion> |
ACTIVITI_VERSIONS |
protected Map<Class<? extends Entity>,List<BulkDeleteOperation>> |
bulkDeleteOperations |
protected static Pattern |
CLEAN_VERSION_REGEX |
protected String |
connectionMetadataDefaultCatalog |
protected String |
connectionMetadataDefaultSchema |
protected DbSqlSessionFactory |
dbSqlSessionFactory |
protected Map<Class<? extends Entity>,Map<String,Entity>> |
deletedObjects |
protected EntityCache |
entityCache |
protected Map<Class<? extends Entity>,Map<String,Entity>> |
insertedObjects |
static String[] |
JDBC_METADATA_TABLE_TYPES |
protected static String |
LAST_V5_VERSION |
protected org.apache.ibatis.session.SqlSession |
sqlSession |
protected List<Entity> |
updatedObjects |
| Constructor and Description |
|---|
DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory,
EntityCache entityCache) |
DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory,
EntityCache entityCache,
Connection connection,
String catalog,
String schema) |
| Modifier and Type | Method and Description |
|---|---|
protected String |
addMissingComponent(String missingComponents,
String component) |
protected String |
addSqlStatementPiece(String sqlStatement,
String line) |
protected Entity |
cacheLoadOrStore(Entity entity)
Returns the object in the cache.
|
protected List |
cacheLoadOrStore(List<Object> loadedObjects) |
void |
close() |
protected void |
collectChildExecutionsForInsertion(List<Entity> result,
Map<String,List<ExecutionEntity>> parentToChildrenMapping,
Set<String> handledExecutionIds,
String parentId,
boolean parentBeforeChildExecution) |
void |
commit() |
DeploymentQueryImpl |
createDeploymentQuery() |
ExecutionQueryImpl |
createExecutionQuery() |
HistoricActivityInstanceQueryImpl |
createHistoricActivityInstanceQuery() |
HistoricDetailQueryImpl |
createHistoricDetailQuery() |
HistoricProcessInstanceQueryImpl |
createHistoricProcessInstanceQuery() |
HistoricTaskInstanceQueryImpl |
createHistoricTaskInstanceQuery() |
HistoricVariableInstanceQueryImpl |
createHistoricVariableInstanceQuery() |
JobQueryImpl |
createJobQuery() |
ModelQueryImpl |
createModelQueryImpl() |
ProcessDefinitionQueryImpl |
createProcessDefinitionQuery() |
ProcessInstanceQueryImpl |
createProcessInstanceQuery() |
TaskQueryImpl |
createTaskQuery() |
void |
dbSchemaCheckVersion() |
void |
dbSchemaCreate() |
protected void |
dbSchemaCreateEngine() |
protected void |
dbSchemaCreateHistory() |
void |
dbSchemaDrop() |
void |
dbSchemaPrune() |
String |
dbSchemaUpdate() |
protected void |
dbSchemaUpgrade(String component,
int currentDatabaseVersionsIndex) |
protected void |
debugFlush() |
void |
delete(Entity entity) |
void |
delete(String statement,
Object parameter,
Class<? extends Entity> entityClass)
Executes a
BulkDeleteOperation, with the sql in the statement parameter. |
void |
determineUpdatedObjects() |
void |
executeMandatorySchemaResource(String operation,
String component) |
void |
executeSchemaResource(String operation,
String component,
String resourceName,
boolean isOptional) |
protected int |
findMatchingVersionIndex(String dbVersion)
Returns the index in the list of
ACTIVITI_VERSIONS matching the provided string version. |
void |
flush() |
protected void |
flushBulkDeletes(Class<? extends Entity> entityClass) |
protected void |
flushBulkInsert(Collection<Entity> entities,
Class<? extends Entity> clazz) |
protected void |
flushDeleteEntities(Class<? extends Entity> entityClass,
Collection<Entity> entitiesToDelete) |
protected void |
flushDeletes() |
protected void |
flushInsertEntities(Class<? extends Entity> entityClass,
Collection<Entity> entitiesToInsert) |
protected void |
flushInserts() |
protected void |
flushRegularInsert(Entity entity,
Class<? extends Entity> clazz) |
protected void |
flushUpdates() |
protected String |
getCleanVersion(String versionString) |
<T> T |
getCustomMapper(Class<T> type) |
DbSqlSessionFactory |
getDbSqlSessionFactory() |
protected String |
getDbVersion() |
String |
getResourceForDbOperation(String directory,
String operation,
String component) |
org.apache.ibatis.session.SqlSession |
getSqlSession() |
protected void |
incrementRevision(Entity insertedObject) |
void |
insert(Entity entity) |
boolean |
isEngineTablePresent() |
boolean |
isEntityInserted(Entity entity) |
boolean |
isEntityToBeDeleted(Entity entity) |
boolean |
isHistoryTablePresent() |
protected boolean |
isMissingTablesException(Exception e) |
boolean |
isMysql() |
boolean |
isOracle() |
boolean |
isTablePresent(String tableName) |
protected boolean |
isUpgradeNeeded(String versionInDatabase) |
protected Collection<Entity> |
orderExecutionEntities(Map<String,Entity> executionEntities,
boolean parentBeforeChildExecution) |
void |
performSchemaOperationsProcessEngineBuild() |
void |
performSchemaOperationsProcessEngineClose() |
protected String |
prependDatabaseTablePrefix(String tableName) |
protected String |
readNextTrimmedLine(BufferedReader reader) |
protected void |
removeUnnecessaryOperations()
Clears all deleted and inserted objects from the cache,
and removes inserts and deletes that cancel each other.
|
void |
rollback() |
<T extends Entity> |
selectById(Class<T> entityClass,
String id) |
<T extends Entity> |
selectById(Class<T> entityClass,
String id,
boolean useCache) |
List |
selectList(String statement) |
List |
selectList(String statement,
ListQueryParameterObject parameter) |
List |
selectList(String statement,
ListQueryParameterObject parameter,
boolean useCache) |
List |
selectList(String statement,
ListQueryParameterObject parameter,
Page page) |
List |
selectList(String statement,
ListQueryParameterObject parameter,
Page page,
boolean useCache) |
List |
selectList(String statement,
Object parameter) |
List |
selectList(String statement,
Object parameter,
boolean useCache) |
List |
selectList(String statement,
Object parameter,
int firstResult,
int maxResults) |
List |
selectList(String statement,
Object parameter,
int firstResult,
int maxResults,
boolean useCache) |
List |
selectList(String statement,
Object parameter,
Page page) |
List |
selectList(String statement,
Object parameter,
Page page,
boolean useCache) |
List |
selectListWithRawParameter(String statement,
Object parameter,
int firstResult,
int maxResults) |
List |
selectListWithRawParameter(String statement,
Object parameter,
int firstResult,
int maxResults,
boolean useCache) |
List |
selectListWithRawParameterWithoutFilter(String statement,
Object parameter,
int firstResult,
int maxResults) |
Object |
selectOne(String statement,
Object parameter) |
void |
update(Entity entity) |
int |
update(String statement,
Object parameters) |
protected String |
updateDdlForMySqlVersionLowerThan56(String ddlStatements)
MySQL is funny when it comes to timestamps and dates.
|
protected static final Pattern CLEAN_VERSION_REGEX
protected static final String LAST_V5_VERSION
protected static final List<ActivitiVersion> ACTIVITI_VERSIONS
protected org.apache.ibatis.session.SqlSession sqlSession
protected DbSqlSessionFactory dbSqlSessionFactory
protected EntityCache entityCache
protected Map<Class<? extends Entity>,List<BulkDeleteOperation>> bulkDeleteOperations
protected String connectionMetadataDefaultCatalog
protected String connectionMetadataDefaultSchema
public static String[] JDBC_METADATA_TABLE_TYPES
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache)
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, EntityCache entityCache, Connection connection, String catalog, String schema)
public void insert(Entity entity)
public void update(Entity entity)
public void delete(String statement, Object parameter, Class<? extends Entity> entityClass)
BulkDeleteOperation, 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 the EntityDependencyOrder.public void delete(Entity entity)
public List selectList(String statement, ListQueryParameterObject parameter, Page page)
public List selectList(String statement, ListQueryParameterObject parameter, Page page, boolean useCache)
public List selectList(String statement, Object parameter, int firstResult, int maxResults)
public List selectList(String statement, Object parameter, int firstResult, int maxResults, boolean useCache)
public List selectList(String statement, ListQueryParameterObject parameter)
public List selectList(String statement, ListQueryParameterObject parameter, boolean useCache)
public List selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults)
public List selectListWithRawParameter(String statement, Object parameter, int firstResult, int maxResults, boolean useCache)
public List selectListWithRawParameterWithoutFilter(String statement, Object parameter, int firstResult, int maxResults)
public <T extends Entity> T selectById(Class<T> entityClass, String id, boolean useCache)
protected Entity cacheLoadOrStore(Entity entity)
protected void removeUnnecessaryOperations()
Also removes deletes with duplicate ids.
public void determineUpdatedObjects()
protected void debugFlush()
public boolean isEntityInserted(Entity entity)
public boolean isEntityToBeDeleted(Entity entity)
protected void flushInserts()
protected void flushInsertEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToInsert)
protected Collection<Entity> orderExecutionEntities(Map<String,Entity> executionEntities, boolean parentBeforeChildExecution)
protected void collectChildExecutionsForInsertion(List<Entity> result, Map<String,List<ExecutionEntity>> parentToChildrenMapping, Set<String> handledExecutionIds, String parentId, boolean parentBeforeChildExecution)
protected void flushBulkInsert(Collection<Entity> entities, Class<? extends Entity> clazz)
protected void incrementRevision(Entity insertedObject)
protected void flushUpdates()
protected void flushDeletes()
protected void flushDeleteEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToDelete)
public void commit()
public void rollback()
public void dbSchemaCheckVersion()
protected String addMissingComponent(String missingComponents, String component)
protected String getDbVersion()
public void dbSchemaCreate()
protected void dbSchemaCreateHistory()
protected void dbSchemaCreateEngine()
public void dbSchemaDrop()
public void dbSchemaPrune()
public void executeMandatorySchemaResource(String operation, String component)
public String dbSchemaUpdate()
protected int findMatchingVersionIndex(String dbVersion)
ACTIVITI_VERSIONS matching the provided string version.
Returns -1 if no match can be found.public boolean isEngineTablePresent()
public boolean isHistoryTablePresent()
public boolean isTablePresent(String tableName)
protected boolean isUpgradeNeeded(String versionInDatabase)
protected void dbSchemaUpgrade(String component, int currentDatabaseVersionsIndex)
public String getResourceForDbOperation(String directory, String operation, String component)
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional)
protected String updateDdlForMySqlVersionLowerThan56(String ddlStatements)
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.
protected String readNextTrimmedLine(BufferedReader reader) throws IOException
IOExceptionprotected boolean isMissingTablesException(Exception e)
public void performSchemaOperationsProcessEngineBuild()
public void performSchemaOperationsProcessEngineClose()
public <T> T getCustomMapper(Class<T> type)
public boolean isMysql()
public boolean isOracle()
public DeploymentQueryImpl createDeploymentQuery()
public ModelQueryImpl createModelQueryImpl()
public ProcessDefinitionQueryImpl createProcessDefinitionQuery()
public ProcessInstanceQueryImpl createProcessInstanceQuery()
public ExecutionQueryImpl createExecutionQuery()
public TaskQueryImpl createTaskQuery()
public JobQueryImpl createJobQuery()
public HistoricProcessInstanceQueryImpl createHistoricProcessInstanceQuery()
public HistoricActivityInstanceQueryImpl createHistoricActivityInstanceQuery()
public HistoricTaskInstanceQueryImpl createHistoricTaskInstanceQuery()
public HistoricDetailQueryImpl createHistoricDetailQuery()
public HistoricVariableInstanceQueryImpl createHistoricVariableInstanceQuery()
public org.apache.ibatis.session.SqlSession getSqlSession()
public DbSqlSessionFactory getDbSqlSessionFactory()
Copyright © 2010–2018 Alfresco. All rights reserved.