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 StringconnectionMetadataDefaultCatalogprotected StringconnectionMetadataDefaultSchemaprotected DbSqlSessionFactorydbSqlSessionFactorystatic String[]JDBC_METADATA_TABLE_TYPESprotected static EnginePersistenceLoggerLOGstatic String[]PG_JDBC_METADATA_TABLE_TYPESprotected org.apache.ibatis.session.SqlSessionsqlSession-
Fields inherited from class org.camunda.bpm.engine.impl.db.AbstractPersistenceSession
listeners
-
-
Constructor Summary
Constructors Constructor Description DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory)DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, Connection connection, String catalog, String schema)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected StringaddSqlStatementPiece(String sqlStatement, String line)protected voidbulkDeletePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)protected voidbulkOperationPerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)protected voidbulkUpdatePerformed(DbBulkOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)voidclose()voidcommit()protected voidconfigureFailedDbEntityOperation(DbEntityOperation operation, org.apache.ibatis.exceptions.PersistenceException failure)voiddbSchemaCheckVersion()protected voiddbSchemaCreateCmmn()protected voiddbSchemaCreateCmmnHistory()protected voiddbSchemaCreateDmn()protected voiddbSchemaCreateDmnHistory()protected voiddbSchemaCreateEngine()protected voiddbSchemaCreateHistory()protected voiddbSchemaCreateIdentity()protected voiddbSchemaDropCmmn()protected voiddbSchemaDropCmmnHistory()protected voiddbSchemaDropDmn()protected voiddbSchemaDropDmnHistory()protected voiddbSchemaDropEngine()protected voiddbSchemaDropHistory()protected voiddbSchemaDropIdentity()protected voidentityDeletePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)protected voidentityInsertPerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)protected voidentityUpdatePerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)protected intexecuteDelete(String deleteStatement, Object parameter)protected voidexecuteInsertEntity(String insertStatement, Object parameter)voidexecuteMandatorySchemaResource(String operation, String component)intexecuteNonEmptyUpdateStmt(String updateStmt, Object parameter)voidexecuteSchemaResource(String schemaFileResourceName)voidexecuteSchemaResource(String operation, String component, String resourceName, boolean isOptional)protected abstract voidexecuteSelectForUpdate(String statement, Object parameter)List<Object>executeSelectList(String statement, Object parameter)intexecuteUpdate(String updateStatement, Object parameter)voidflush()List<org.apache.ibatis.executor.BatchResult>flushBatchOperations()voidflushOperations()DbSqlSessionFactorygetDbSqlSessionFactory()protected StringgetDbVersion()StringgetResourceForDbOperation(String directory, String operation, String component)org.apache.ibatis.session.SqlSessiongetSqlSession()List<String>getTableNamesPresent()protected List<String>getTablesPresentInOracleDatabase()protected String[]getTableTypes()protected voidinsertEntity(DbEntityOperation operation)booleanisCmmnHistoryTablePresent()booleanisCmmnTablePresent()protected booleanisConcurrentModificationException(DbOperation failedOperation, org.apache.ibatis.exceptions.PersistenceException cause)static booleanisCrdbConcurrencyConflict(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 booleanisCrdbConcurrencyConflictOnCommit(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.booleanisDmnHistoryTablePresent()booleanisDmnTablePresent()booleanisEngineTablePresent()booleanisHistoryTablePresent()booleanisIdentityTablePresent()protected booleanisMissingTablesException(Exception e)booleanisTablePresent(String tableName)voidlock(String statement, Object parameter)StringprependDatabaseTablePrefix(String tableName)protected StringreadNextTrimmedLine(BufferedReader reader)voidrollback()<T extends DbEntity>
TselectById(Class<T> type, String id)List<?>selectList(String statement, Object parameter)ObjectselectOne(String statement, Object parameter)intupdate(String updateStatement, 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 String[] JDBC_METADATA_TABLE_TYPES
-
PG_JDBC_METADATA_TABLE_TYPES
public static final String[] PG_JDBC_METADATA_TABLE_TYPES
-
sqlSession
protected org.apache.ibatis.session.SqlSession sqlSession
-
dbSqlSessionFactory
protected DbSqlSessionFactory dbSqlSessionFactory
-
connectionMetadataDefaultCatalog
protected String connectionMetadataDefaultCatalog
-
connectionMetadataDefaultSchema
protected String connectionMetadataDefaultSchema
-
-
Constructor Detail
-
DbSqlSession
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory)
-
DbSqlSession
public DbSqlSession(DbSqlSessionFactory dbSqlSessionFactory, Connection connection, String catalog, String schema)
-
-
Method Detail
-
executeSelectForUpdate
protected abstract void executeSelectForUpdate(String statement, 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(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(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:
insertEntityin classAbstractPersistenceSession
-
entityInsertPerformed
protected void entityInsertPerformed(DbEntityOperation operation, int rowsAffected, org.apache.ibatis.exceptions.PersistenceException failure)
-
executeNonEmptyUpdateStmt
public int executeNonEmptyUpdateStmt(String updateStmt, Object parameter)
-
flush
public void flush()
-
flushOperations
public void flushOperations()
-
flushBatchOperations
public 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 String getDbVersion()
- Specified by:
getDbVersionin classAbstractPersistenceSession
-
dbSchemaCreateIdentity
protected void dbSchemaCreateIdentity()
- Specified by:
dbSchemaCreateIdentityin classAbstractPersistenceSession
-
dbSchemaCreateHistory
protected void dbSchemaCreateHistory()
- Specified by:
dbSchemaCreateHistoryin classAbstractPersistenceSession
-
dbSchemaCreateEngine
protected void dbSchemaCreateEngine()
- Specified by:
dbSchemaCreateEnginein classAbstractPersistenceSession
-
dbSchemaCreateCmmn
protected void dbSchemaCreateCmmn()
- Specified by:
dbSchemaCreateCmmnin classAbstractPersistenceSession
-
dbSchemaCreateCmmnHistory
protected void dbSchemaCreateCmmnHistory()
- Specified by:
dbSchemaCreateCmmnHistoryin classAbstractPersistenceSession
-
dbSchemaCreateDmn
protected void dbSchemaCreateDmn()
- Specified by:
dbSchemaCreateDmnin classAbstractPersistenceSession
-
dbSchemaCreateDmnHistory
protected void dbSchemaCreateDmnHistory()
- Specified by:
dbSchemaCreateDmnHistoryin classAbstractPersistenceSession
-
dbSchemaDropIdentity
protected void dbSchemaDropIdentity()
- Specified by:
dbSchemaDropIdentityin classAbstractPersistenceSession
-
dbSchemaDropHistory
protected void dbSchemaDropHistory()
- Specified by:
dbSchemaDropHistoryin classAbstractPersistenceSession
-
dbSchemaDropEngine
protected void dbSchemaDropEngine()
- Specified by:
dbSchemaDropEnginein classAbstractPersistenceSession
-
dbSchemaDropCmmn
protected void dbSchemaDropCmmn()
- Specified by:
dbSchemaDropCmmnin classAbstractPersistenceSession
-
dbSchemaDropCmmnHistory
protected void dbSchemaDropCmmnHistory()
- Specified by:
dbSchemaDropCmmnHistoryin classAbstractPersistenceSession
-
dbSchemaDropDmn
protected void dbSchemaDropDmn()
- Specified by:
dbSchemaDropDmnin classAbstractPersistenceSession
-
dbSchemaDropDmnHistory
protected void dbSchemaDropDmnHistory()
- Specified by:
dbSchemaDropDmnHistoryin classAbstractPersistenceSession
-
executeMandatorySchemaResource
public void executeMandatorySchemaResource(String operation, String component)
-
isEngineTablePresent
public boolean isEngineTablePresent()
- Specified by:
isEngineTablePresentin classAbstractPersistenceSession
-
isHistoryTablePresent
public boolean isHistoryTablePresent()
- Specified by:
isHistoryTablePresentin classAbstractPersistenceSession
-
isIdentityTablePresent
public boolean isIdentityTablePresent()
- Specified by:
isIdentityTablePresentin classAbstractPersistenceSession
-
isCmmnTablePresent
public boolean isCmmnTablePresent()
- Specified by:
isCmmnTablePresentin classAbstractPersistenceSession
-
isCmmnHistoryTablePresent
public boolean isCmmnHistoryTablePresent()
- Specified by:
isCmmnHistoryTablePresentin classAbstractPersistenceSession
-
isDmnTablePresent
public boolean isDmnTablePresent()
- Specified by:
isDmnTablePresentin classAbstractPersistenceSession
-
isDmnHistoryTablePresent
public boolean isDmnHistoryTablePresent()
- Specified by:
isDmnHistoryTablePresentin classAbstractPersistenceSession
-
isTablePresent
public boolean isTablePresent(String tableName)
-
getTableNamesPresent
public List<String> getTableNamesPresent()
- Specified by:
getTableNamesPresentin interfacePersistenceSession- Overrides:
getTableNamesPresentin classAbstractPersistenceSession
-
getTablesPresentInOracleDatabase
protected List<String> getTablesPresentInOracleDatabase() throws SQLException
- Throws:
SQLException
-
getResourceForDbOperation
public String getResourceForDbOperation(String directory, String operation, String component)
-
executeSchemaResource
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional)
-
executeSchemaResource
public void executeSchemaResource(String schemaFileResourceName)
-
readNextTrimmedLine
protected String readNextTrimmedLine(BufferedReader reader) throws IOException
- Throws:
IOException
-
isMissingTablesException
protected boolean isMissingTablesException(Exception e)
-
getTableTypes
protected String[] getTableTypes()
-
getSqlSession
public org.apache.ibatis.session.SqlSession getSqlSession()
-
getDbSqlSessionFactory
public DbSqlSessionFactory getDbSqlSessionFactory()
-
-