Class DbSqlSession

    • Field Detail

      • LAST_V5_VERSION

        protected static final java.lang.String LAST_V5_VERSION
        See Also:
        Constant Field Values
      • ACTIVITI_VERSIONS

        protected static final java.util.List<ActivitiVersion> ACTIVITI_VERSIONS
      • sqlSession

        protected org.apache.ibatis.session.SqlSession sqlSession
      • insertedObjects

        protected java.util.Map<java.lang.Class<? extends Entity>,​java.util.Map<java.lang.String,​Entity>> insertedObjects
      • deletedObjects

        protected java.util.Map<java.lang.Class<? extends Entity>,​java.util.Map<java.lang.String,​Entity>> deletedObjects
      • bulkDeleteOperations

        protected java.util.Map<java.lang.Class<? extends Entity>,​java.util.List<BulkDeleteOperation>> bulkDeleteOperations
      • updatedObjects

        protected java.util.List<Entity> updatedObjects
      • connectionMetadataDefaultCatalog

        protected java.lang.String connectionMetadataDefaultCatalog
      • connectionMetadataDefaultSchema

        protected java.lang.String connectionMetadataDefaultSchema
      • JDBC_METADATA_TABLE_TYPES

        public static java.lang.String[] JDBC_METADATA_TABLE_TYPES
    • Constructor Detail

      • DbSqlSession

        public DbSqlSession​(DbSqlSessionFactory dbSqlSessionFactory,
                            EntityCache entityCache,
                            java.sql.Connection connection,
                            java.lang.String catalog,
                            java.lang.String schema)
    • Method Detail

      • insert

        public void insert​(Entity entity)
      • update

        public void update​(Entity entity)
      • update

        public int update​(java.lang.String statement,
                          java.lang.Object parameters)
      • delete

        public void delete​(java.lang.String statement,
                           java.lang.Object parameter,
                           java.lang.Class<? extends Entity> entityClass)
        Executes a 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.
      • delete

        public void delete​(Entity entity)
      • 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,
                                         boolean useCache)
      • 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,
                                         java.lang.Object parameter,
                                         Page page,
                                         boolean useCache)
      • selectList

        public java.util.List selectList​(java.lang.String statement,
                                         ListQueryParameterObject parameter,
                                         Page page,
                                         boolean useCache)
      • 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,
                                         java.lang.Object parameter,
                                         int firstResult,
                                         int maxResults,
                                         boolean useCache)
      • selectList

        public java.util.List selectList​(java.lang.String statement,
                                         ListQueryParameterObject parameter,
                                         boolean useCache)
      • selectListWithRawParameter

        public java.util.List selectListWithRawParameter​(java.lang.String statement,
                                                         java.lang.Object parameter,
                                                         int firstResult,
                                                         int maxResults)
      • selectListWithRawParameter

        public java.util.List selectListWithRawParameter​(java.lang.String statement,
                                                         java.lang.Object parameter,
                                                         int firstResult,
                                                         int maxResults,
                                                         boolean useCache)
      • selectListWithRawParameterWithoutFilter

        public java.util.List selectListWithRawParameterWithoutFilter​(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)
      • selectById

        public <T extends Entity> T selectById​(java.lang.Class<T> entityClass,
                                               java.lang.String id)
      • selectById

        public <T extends Entity> T selectById​(java.lang.Class<T> entityClass,
                                               java.lang.String id,
                                               boolean useCache)
      • cacheLoadOrStore

        protected java.util.List cacheLoadOrStore​(java.util.List<java.lang.Object> loadedObjects)
      • cacheLoadOrStore

        protected Entity cacheLoadOrStore​(Entity entity)
        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()
        Specified by:
        flush in interface Session
      • 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

        public boolean isEntityInserted​(Entity entity)
      • isEntityToBeDeleted

        public boolean isEntityToBeDeleted​(Entity entity)
      • flushInserts

        protected void flushInserts()
      • flushInsertEntities

        protected void flushInsertEntities​(java.lang.Class<? extends Entity> entityClass,
                                           java.util.Collection<Entity> entitiesToInsert)
      • orderExecutionEntities

        protected java.util.Collection<Entity> orderExecutionEntities​(java.util.Map<java.lang.String,​Entity> executionEntities,
                                                                      boolean parentBeforeChildExecution)
      • collectChildExecutionsForInsertion

        protected void collectChildExecutionsForInsertion​(java.util.List<Entity> result,
                                                          java.util.Map<java.lang.String,​java.util.List<ExecutionEntity>> parentToChildrenMapping,
                                                          java.util.Set<java.lang.String> handledExecutionIds,
                                                          java.lang.String parentId,
                                                          boolean parentBeforeChildExecution)
      • flushRegularInsert

        protected void flushRegularInsert​(Entity entity,
                                          java.lang.Class<? extends Entity> clazz)
      • flushBulkInsert

        protected void flushBulkInsert​(java.util.Collection<Entity> entities,
                                       java.lang.Class<? extends Entity> clazz)
      • incrementRevision

        protected void incrementRevision​(Entity insertedObject)
      • flushUpdates

        protected void flushUpdates()
      • flushDeletes

        protected void flushDeletes()
      • flushBulkDeletes

        protected void flushBulkDeletes​(java.lang.Class<? extends Entity> entityClass)
      • flushDeleteEntities

        protected void flushDeleteEntities​(java.lang.Class<? extends Entity> entityClass,
                                           java.util.Collection<Entity> entitiesToDelete)
      • close

        public void close()
        Specified by:
        close in interface Session
      • commit

        public void commit()
      • rollback

        public void rollback()
      • dbSchemaCheckVersion

        public void dbSchemaCheckVersion()
      • addMissingComponent

        protected java.lang.String addMissingComponent​(java.lang.String missingComponents,
                                                       java.lang.String component)
      • getDbVersion

        protected java.lang.String getDbVersion()
      • dbSchemaCreate

        public void dbSchemaCreate()
      • dbSchemaCreateHistory

        protected void dbSchemaCreateHistory()
      • dbSchemaCreateEngine

        protected void dbSchemaCreateEngine()
      • dbSchemaDrop

        public void dbSchemaDrop()
      • dbSchemaPrune

        public void dbSchemaPrune()
      • executeMandatorySchemaResource

        public void executeMandatorySchemaResource​(java.lang.String operation,
                                                   java.lang.String component)
      • dbSchemaUpdate

        public java.lang.String dbSchemaUpdate()
      • findMatchingVersionIndex

        protected int findMatchingVersionIndex​(java.lang.String dbVersion)
        Returns the index in the list of ACTIVITI_VERSIONS matching the provided string version. Returns -1 if no match can be found.
      • isEngineTablePresent

        public boolean isEngineTablePresent()
      • isHistoryTablePresent

        public boolean isHistoryTablePresent()
      • isTablePresent

        public boolean isTablePresent​(java.lang.String tableName)
      • prependDatabaseTablePrefix

        protected java.lang.String prependDatabaseTablePrefix​(java.lang.String tableName)
      • dbSchemaUpgrade

        protected void dbSchemaUpgrade​(java.lang.String component,
                                       int currentDatabaseVersionsIndex)
      • getResourceForDbOperation

        public java.lang.String getResourceForDbOperation​(java.lang.String directory,
                                                          java.lang.String operation,
                                                          java.lang.String component)
      • executeSchemaResource

        public void executeSchemaResource​(java.lang.String operation,
                                          java.lang.String component,
                                          java.lang.String resourceName,
                                          boolean isOptional)
      • updateDdlForMySqlVersionLowerThan56

        protected java.lang.String updateDdlForMySqlVersionLowerThan56​(java.lang.String ddlStatements)
        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

        protected java.lang.String addSqlStatementPiece​(java.lang.String sqlStatement,
                                                        java.lang.String line)
      • readNextTrimmedLine

        protected java.lang.String readNextTrimmedLine​(java.io.BufferedReader reader)
                                                throws java.io.IOException
        Throws:
        java.io.IOException
      • isMissingTablesException

        protected boolean isMissingTablesException​(java.lang.Exception e)
      • performSchemaOperationsProcessEngineBuild

        public void performSchemaOperationsProcessEngineBuild()
      • performSchemaOperationsProcessEngineClose

        public void performSchemaOperationsProcessEngineClose()
      • getCustomMapper

        public <T> T getCustomMapper​(java.lang.Class<T> type)
      • isMysql

        public boolean isMysql()
      • isOracle

        public boolean isOracle()
      • getSqlSession

        public org.apache.ibatis.session.SqlSession getSqlSession()