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 String
connectionMetadataDefaultCatalog
protected String
connectionMetadataDefaultSchema
protected DbSqlSessionFactory
dbSqlSessionFactory
static String[]
JDBC_METADATA_TABLE_TYPES
protected static EnginePersistenceLogger
LOG
static 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, Connection connection, String catalog, String schema)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected String
addSqlStatementPiece(String sqlStatement, 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(String deleteStatement, Object parameter)
protected void
executeInsertEntity(String insertStatement, Object parameter)
void
executeMandatorySchemaResource(String operation, String component)
int
executeNonEmptyUpdateStmt(String updateStmt, Object parameter)
void
executeSchemaResource(String schemaFileResourceName)
void
executeSchemaResource(String operation, String component, String resourceName, boolean isOptional)
protected abstract void
executeSelectForUpdate(String statement, Object parameter)
List<Object>
executeSelectList(String statement, Object parameter)
int
executeUpdate(String updateStatement, Object parameter)
void
flush()
List<org.apache.ibatis.executor.BatchResult>
flushBatchOperations()
void
flushOperations()
DbSqlSessionFactory
getDbSqlSessionFactory()
protected String
getDbVersion()
String
getResourceForDbOperation(String directory, String operation, String component)
org.apache.ibatis.session.SqlSession
getSqlSession()
List<String>
getTableNamesPresent()
protected List<String>
getTablesPresentInOracleDatabase()
protected 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(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(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(Exception e)
boolean
isTablePresent(String tableName)
void
lock(String statement, Object parameter)
String
prependDatabaseTablePrefix(String tableName)
protected String
readNextTrimmedLine(BufferedReader reader)
void
rollback()
<T extends DbEntity>
TselectById(Class<T> type, String id)
List<?>
selectList(String statement, Object parameter)
Object
selectOne(String statement, Object parameter)
int
update(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:
insertEntity
in 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:
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(String operation, 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(String tableName)
-
getTableNamesPresent
public List<String> getTableNamesPresent()
- Specified by:
getTableNamesPresent
in interfacePersistenceSession
- Overrides:
getTableNamesPresent
in 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()
-
-