Class DbSqlSession
- java.lang.Object
-
- org.camunda.bpm.engine.impl.db.AbstractPersistenceSession
-
- org.camunda.bpm.engine.impl.db.sql.DbSqlSession
-
- All Implemented Interfaces:
PersistenceSession
,Session
- Direct Known Subclasses:
BatchDbSqlSession
,SimpleDbSqlSession
public abstract class DbSqlSession extends AbstractPersistenceSession
- Author:
- Tom Baeyens, Joram Barrez, Daniel Meyer, Sebastian Menski, Roman Smirnov
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
connectionMetadataDefaultCatalog
protected java.lang.String
connectionMetadataDefaultSchema
protected DbSqlSessionFactory
dbSqlSessionFactory
static java.lang.String[]
JDBC_METADATA_TABLE_TYPES
protected static EnginePersistenceLogger
LOG
static java.lang.String[]
PG_JDBC_METADATA_TABLE_TYPES
protected org.apache.ibatis.session.SqlSession
sqlSession
-
Fields inherited from class org.camunda.bpm.engine.impl.db.AbstractPersistenceSession
listeners
-
-
Constructor Summary
Constructors Constructor Description DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory)
DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, java.sql.Connection connection, java.lang.String catalog, java.lang.String schema)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
addSqlStatementPiece(java.lang.String sqlStatement, java.lang.String line)
protected void
bulkDeletePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
protected void
bulkOperationPerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
protected void
bulkUpdatePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
void
close()
void
commit()
protected void
configureFailedDbEntityOperation(DbEntityOperation operation, org.apache.ibatis.exceptions.PersistenceException failure)
void
dbSchemaCheckVersion()
protected void
dbSchemaCreateCmmn()
protected void
dbSchemaCreateCmmnHistory()
protected void
dbSchemaCreateDmn()
protected void
dbSchemaCreateDmnHistory()
protected void
dbSchemaCreateEngine()
protected void
dbSchemaCreateHistory()
protected void
dbSchemaCreateIdentity()
protected void
dbSchemaDropCmmn()
protected void
dbSchemaDropCmmnHistory()
protected void
dbSchemaDropDmn()
protected void
dbSchemaDropDmnHistory()
protected void
dbSchemaDropEngine()
protected void
dbSchemaDropHistory()
protected void
dbSchemaDropIdentity()
protected void
entityDeletePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
protected void
entityInsertPerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
protected void
entityUpdatePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
protected int
executeDelete(java.lang.String deleteStatement, java.lang.Object parameter)
protected void
executeInsertEntity(java.lang.String insertStatement, java.lang.Object parameter)
void
executeMandatorySchemaResource(java.lang.String operation, java.lang.String component)
int
executeNonEmptyUpdateStmt(java.lang.String updateStmt, java.lang.Object parameter)
void
executeSchemaResource(java.lang.String schemaFileResourceName)
void
executeSchemaResource(java.lang.String operation, java.lang.String component, java.lang.String resourceName, boolean isOptional)
protected abstract void
executeSelectForUpdate(java.lang.String statement, java.lang.Object parameter)
java.util.List<java.lang.Object>
executeSelectList(java.lang.String statement, java.lang.Object parameter)
int
executeUpdate(java.lang.String updateStatement, java.lang.Object parameter)
void
flush()
java.util.List<org.apache.ibatis.executor.BatchResult>
flushBatchOperations()
void
flushOperations()
DbSqlSessionFactory
getDbSqlSessionFactory()
protected java.lang.String
getDbVersion()
java.lang.String
getResourceForDbOperation(java.lang.String directory, java.lang.String operation, java.lang.String component)
org.apache.ibatis.session.SqlSession
getSqlSession()
java.util.List<java.lang.String>
getTableNamesPresent()
protected java.util.List<java.lang.String>
getTablesPresentInOracleDatabase()
protected java.lang.String[]
getTableTypes()
protected void
insertEntity(DbEntityOperation operation)
boolean
isCmmnHistoryTablePresent()
boolean
isCmmnTablePresent()
protected boolean
isConcurrentModificationException(DbOperation failedOperation, org.apache.ibatis.exceptions.PersistenceException cause)
static boolean
isCrdbConcurrencyConflict(java.lang.Throwable cause)
In cases where CockroachDB is used, and a failed operation is detected, the method checks if the exception was caused by a CockroachDBTransactionRetryException
.static boolean
isCrdbConcurrencyConflictOnCommit(java.lang.Exception cause, ProcessEngineConfigurationImpl configuration)
In cases where CockroachDB is used, and a failed operation is detected, the method checks if the exception was caused by a CockroachDBTransactionRetryException
.boolean
isDmnHistoryTablePresent()
boolean
isDmnTablePresent()
boolean
isEngineTablePresent()
boolean
isHistoryTablePresent()
boolean
isIdentityTablePresent()
protected boolean
isMissingTablesException(java.lang.Exception e)
boolean
isTablePresent(java.lang.String tableName)
void
lock(java.lang.String statement, java.lang.Object parameter)
java.lang.String
prependDatabaseTablePrefix(java.lang.String tableName)
protected java.lang.String
readNextTrimmedLine(java.io.BufferedReader reader)
void
rollback()
<T extends DbEntity>
TselectById(java.lang.Class<T> type, java.lang.String id)
java.util.List<?>
selectList(java.lang.String statement, java.lang.Object parameter)
java.lang.Object
selectOne(java.lang.String statement, java.lang.Object parameter)
int
update(java.lang.String updateStatement, java.lang.Object parameter)
-
Methods inherited from class org.camunda.bpm.engine.impl.db.AbstractPersistenceSession
addEntityLoadListener, dbSchemaCreate, dbSchemaDrop, dbSchemaPrune, dbSchemaUpdate, deleteBulk, deleteEntity, executeDbOperation, fireEntityLoaded, updateBulk, updateEntity
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.camunda.bpm.engine.impl.db.PersistenceSession
executeDbOperations
-
-
-
-
Field Detail
-
LOG
protected static final EnginePersistenceLogger LOG
-
JDBC_METADATA_TABLE_TYPES
public static final java.lang.String[] JDBC_METADATA_TABLE_TYPES
-
PG_JDBC_METADATA_TABLE_TYPES
public static final java.lang.String[] PG_JDBC_METADATA_TABLE_TYPES
-
sqlSession
protected org.apache.ibatis.session.SqlSession sqlSession
-
dbSqlSessionFactory
protected DbSqlSessionFactory dbSqlSessionFactory
-
connectionMetadataDefaultCatalog
protected java.lang.String connectionMetadataDefaultCatalog
-
connectionMetadataDefaultSchema
protected java.lang.String connectionMetadataDefaultSchema
-
-
Constructor Detail
-
DbSqlSession
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory)
-
DbSqlSession
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, java.sql.Connection connection, java.lang.String catalog, java.lang.String schema)
-
-
Method Detail
-
selectList
public java.util.List<?> selectList(java.lang.String statement, java.lang.Object parameter)
-
executeSelectList
public java.util.List<java.lang.Object> executeSelectList(java.lang.String statement, java.lang.Object parameter)
-
selectById
public <T extends DbEntity> T selectById(java.lang.Class<T> type, java.lang.String id)
-
selectOne
public java.lang.Object selectOne(java.lang.String statement, java.lang.Object parameter)
-
lock
public void lock(java.lang.String statement, java.lang.Object parameter)
-
executeSelectForUpdate
protected abstract void executeSelectForUpdate(java.lang.String statement, java.lang.Object parameter)
-
entityUpdatePerformed
protected void entityUpdatePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
bulkUpdatePerformed
protected void bulkUpdatePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
bulkDeletePerformed
protected void bulkDeletePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
bulkOperationPerformed
protected void bulkOperationPerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
entityDeletePerformed
protected void entityDeletePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
configureFailedDbEntityOperation
protected void configureFailedDbEntityOperation(DbEntityOperation operation, org.apache.ibatis.exceptions.PersistenceException failure)
-
isConcurrentModificationException
protected boolean isConcurrentModificationException(DbOperation failedOperation, org.apache.ibatis.exceptions.PersistenceException cause)
-
isCrdbConcurrencyConflict
public static boolean isCrdbConcurrencyConflict(java.lang.Throwable cause)
In cases where CockroachDB is used, and a failed operation is detected, the method checks if the exception was caused by a CockroachDBTransactionRetryException
.- Parameters:
cause
- for which an operation failed- Returns:
- true if the failure was due to a CRDB
TransactionRetryException
. Otherwise, it's false.
-
isCrdbConcurrencyConflictOnCommit
public static boolean isCrdbConcurrencyConflictOnCommit(java.lang.Exception cause, ProcessEngineConfigurationImpl configuration)
In cases where CockroachDB is used, and a failed operation is detected, the method checks if the exception was caused by a CockroachDBTransactionRetryException
. This method may be used when a CRDB Error occurs on commit, and a Command Context is not available, as it has already been closed. This is the case with Spring/JTA transaction interceptors.- Parameters:
cause
- for which an operation failedconfiguration
- of the Process Engine- Returns:
- true if the failure was due to a CRDB
TransactionRetryException
. Otherwise, it's false.
-
insertEntity
protected void insertEntity(DbEntityOperation operation)
- Specified by:
insertEntity
in classAbstractPersistenceSession
-
executeInsertEntity
protected void executeInsertEntity(java.lang.String insertStatement, java.lang.Object parameter)
-
entityInsertPerformed
protected void entityInsertPerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
executeDelete
protected int executeDelete(java.lang.String deleteStatement, java.lang.Object parameter)
-
executeUpdate
public int executeUpdate(java.lang.String updateStatement, java.lang.Object parameter)
-
update
public int update(java.lang.String updateStatement, java.lang.Object parameter)
-
executeNonEmptyUpdateStmt
public int executeNonEmptyUpdateStmt(java.lang.String updateStmt, java.lang.Object parameter)
-
flush
public void flush()
-
flushOperations
public void flushOperations()
-
flushBatchOperations
public java.util.List<org.apache.ibatis.executor.BatchResult> flushBatchOperations()
-
close
public void close()
-
commit
public void commit()
-
rollback
public void rollback()
-
dbSchemaCheckVersion
public void dbSchemaCheckVersion()
-
getDbVersion
protected java.lang.String getDbVersion()
- Specified by:
getDbVersion
in classAbstractPersistenceSession
-
dbSchemaCreateIdentity
protected void dbSchemaCreateIdentity()
- Specified by:
dbSchemaCreateIdentity
in classAbstractPersistenceSession
-
dbSchemaCreateHistory
protected void dbSchemaCreateHistory()
- Specified by:
dbSchemaCreateHistory
in classAbstractPersistenceSession
-
dbSchemaCreateEngine
protected void dbSchemaCreateEngine()
- Specified by:
dbSchemaCreateEngine
in classAbstractPersistenceSession
-
dbSchemaCreateCmmn
protected void dbSchemaCreateCmmn()
- Specified by:
dbSchemaCreateCmmn
in classAbstractPersistenceSession
-
dbSchemaCreateCmmnHistory
protected void dbSchemaCreateCmmnHistory()
- Specified by:
dbSchemaCreateCmmnHistory
in classAbstractPersistenceSession
-
dbSchemaCreateDmn
protected void dbSchemaCreateDmn()
- Specified by:
dbSchemaCreateDmn
in classAbstractPersistenceSession
-
dbSchemaCreateDmnHistory
protected void dbSchemaCreateDmnHistory()
- Specified by:
dbSchemaCreateDmnHistory
in classAbstractPersistenceSession
-
dbSchemaDropIdentity
protected void dbSchemaDropIdentity()
- Specified by:
dbSchemaDropIdentity
in classAbstractPersistenceSession
-
dbSchemaDropHistory
protected void dbSchemaDropHistory()
- Specified by:
dbSchemaDropHistory
in classAbstractPersistenceSession
-
dbSchemaDropEngine
protected void dbSchemaDropEngine()
- Specified by:
dbSchemaDropEngine
in classAbstractPersistenceSession
-
dbSchemaDropCmmn
protected void dbSchemaDropCmmn()
- Specified by:
dbSchemaDropCmmn
in classAbstractPersistenceSession
-
dbSchemaDropCmmnHistory
protected void dbSchemaDropCmmnHistory()
- Specified by:
dbSchemaDropCmmnHistory
in classAbstractPersistenceSession
-
dbSchemaDropDmn
protected void dbSchemaDropDmn()
- Specified by:
dbSchemaDropDmn
in classAbstractPersistenceSession
-
dbSchemaDropDmnHistory
protected void dbSchemaDropDmnHistory()
- Specified by:
dbSchemaDropDmnHistory
in classAbstractPersistenceSession
-
executeMandatorySchemaResource
public void executeMandatorySchemaResource(java.lang.String operation, java.lang.String component)
-
isEngineTablePresent
public boolean isEngineTablePresent()
- Specified by:
isEngineTablePresent
in classAbstractPersistenceSession
-
isHistoryTablePresent
public boolean isHistoryTablePresent()
- Specified by:
isHistoryTablePresent
in classAbstractPersistenceSession
-
isIdentityTablePresent
public boolean isIdentityTablePresent()
- Specified by:
isIdentityTablePresent
in classAbstractPersistenceSession
-
isCmmnTablePresent
public boolean isCmmnTablePresent()
- Specified by:
isCmmnTablePresent
in classAbstractPersistenceSession
-
isCmmnHistoryTablePresent
public boolean isCmmnHistoryTablePresent()
- Specified by:
isCmmnHistoryTablePresent
in classAbstractPersistenceSession
-
isDmnTablePresent
public boolean isDmnTablePresent()
- Specified by:
isDmnTablePresent
in classAbstractPersistenceSession
-
isDmnHistoryTablePresent
public boolean isDmnHistoryTablePresent()
- Specified by:
isDmnHistoryTablePresent
in classAbstractPersistenceSession
-
isTablePresent
public boolean isTablePresent(java.lang.String tableName)
-
getTableNamesPresent
public java.util.List<java.lang.String> getTableNamesPresent()
- Specified by:
getTableNamesPresent
in interfacePersistenceSession
- Overrides:
getTableNamesPresent
in classAbstractPersistenceSession
-
getTablesPresentInOracleDatabase
protected java.util.List<java.lang.String> getTablesPresentInOracleDatabase() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
prependDatabaseTablePrefix
public java.lang.String prependDatabaseTablePrefix(java.lang.String tableName)
-
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)
-
executeSchemaResource
public void executeSchemaResource(java.lang.String schemaFileResourceName)
-
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)
-
getTableTypes
protected java.lang.String[] getTableTypes()
-
getSqlSession
public org.apache.ibatis.session.SqlSession getSqlSession()
-
getDbSqlSessionFactory
public DbSqlSessionFactory getDbSqlSessionFactory()
-
-