Package org.jumpmind.db.sql
Class JdbcSqlTransaction
java.lang.Object
org.jumpmind.db.sql.JdbcSqlTransaction
- All Implemented Interfaces:
ISqlTransaction
- Direct Known Subclasses:
AseJdbcSqlTransaction,H2JdbcSqlTransaction,MsSqlJdbcSqlTransaction
TODO Support Oracle's non-standard way of batching
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected intprotected Connectionprotected booleanprotected JdbcSqlTemplateprotected List<ISqlTransactionListener>protected LogSqlBuilderprotected booleanprotected Stringprotected PreparedStatement -
Constructor Summary
ConstructorsConstructorDescriptionJdbcSqlTransaction(JdbcSqlTemplate jdbcSqlTemplate) JdbcSqlTransaction(JdbcSqlTemplate jdbcSqlTemplate, boolean autoCommit) -
Method Summary
Modifier and TypeMethodDescriptionintvoidvoidallowInsertIntoAutoIncrementColumns(boolean value, Table table, String quote, String catalogSeparator, String schemaSepartor) Indicate that the current session is to allow updates to columns that have been marked as auto increment.voidvoidclose()voidcommit()intprotected intexecuteAllowingResults(PreparedStatement preparedStatement) <T> TexecuteCallback(IConnectionCallback<T> callback) protected intexecutePreparedUpdate(PreparedStatement preparedStatement, String sql, Object[] args, int[] argTypes) intflush()intgetUnflushedMarkers(boolean clear) protected final voidinit()longinsertWithGeneratedKey(String sql, String column, String sequenceName, Object[] args, int[] types) booleanbooleanprotected final intnormalizeUpdateCount(int value) According to the executeUpdate() javadoc -2 means that the result was successful, but that the number of rows affected is unknown.voidEach time the SQL changes it needs to be submitted for preparationintprepareAndExecute(String sql, Object... args) intprepareAndExecute(String sql, Object[] args, int[] types) intprepareAndExecute(String sql, Map<String, Object> args) <T> List<T>query(String sql, ISqlRowMapper<T> mapper, Object[] args, int[] types) <T> List<T>intqueryForInt(String sql, Object... args) longqueryForLong(String sql, Object... args) <T> TqueryForObject(String sql, Class<T> clazz, Object... args) queryForRow(String sql, Object... args) protected voidvoidrollback()protected voidrollback(boolean clearMarkers) voidsetBatchSize(int batchSize) voidsetInBatchMode(boolean useBatching) voidsetLogSqlBuilder(LogSqlBuilder logSqlBuilder)
-
Field Details
-
inBatchMode
protected boolean inBatchMode -
connection
-
psql
-
pstmt
-
jdbcSqlTemplate
-
autoCommit
protected boolean autoCommit -
oldAutoCommitValue
protected boolean oldAutoCommitValue -
markers
-
logSqlBuilder
-
listeners
-
batchSize
protected int batchSize
-
-
Constructor Details
-
JdbcSqlTransaction
-
JdbcSqlTransaction
-
-
Method Details
-
addSqlTransactionListener
- Specified by:
addSqlTransactionListenerin interfaceISqlTransaction
-
init
protected final void init() -
setInBatchMode
public void setInBatchMode(boolean useBatching) - Specified by:
setInBatchModein interfaceISqlTransaction
-
isInBatchMode
public boolean isInBatchMode()- Specified by:
isInBatchModein interfaceISqlTransaction
-
commit
public void commit()- Specified by:
commitin interfaceISqlTransaction
-
rollback
public void rollback()- Specified by:
rollbackin interfaceISqlTransaction
-
rollback
protected void rollback(boolean clearMarkers) -
close
public void close()- Specified by:
closein interfaceISqlTransaction
-
flush
public int flush()- Specified by:
flushin interfaceISqlTransaction
-
queryForRow
- Specified by:
queryForRowin interfaceISqlTransaction
-
queryForInt
- Specified by:
queryForIntin interfaceISqlTransaction
-
queryForLong
- Specified by:
queryForLongin interfaceISqlTransaction
-
queryForObject
- Specified by:
queryForObjectin interfaceISqlTransaction
-
query
- Specified by:
queryin interfaceISqlTransaction
-
query
- Specified by:
queryin interfaceISqlTransaction
-
execute
- Specified by:
executein interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecutein interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecutein interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecutein interfaceISqlTransaction
-
executeCallback
-
normalizeUpdateCount
protected final int normalizeUpdateCount(int value) According to the executeUpdate() javadoc -2 means that the result was successful, but that the number of rows affected is unknown. since we know that only one row is suppose to be affected, we'll default to 1.- Parameters:
value-
-
removeMarkersThatWereSuccessful
-
prepare
Description copied from interface:ISqlTransactionEach time the SQL changes it needs to be submitted for preparation- Specified by:
preparein interfaceISqlTransaction
-
addRow
- Specified by:
addRowin interfaceISqlTransaction
-
setBatchSize
public void setBatchSize(int batchSize) -
getBatchSize
public int getBatchSize() -
executePreparedUpdate
protected int executePreparedUpdate(PreparedStatement preparedStatement, String sql, Object[] args, int[] argTypes) throws SQLException - Throws:
SQLException
-
executeAllowingResults
- Throws:
SQLException
-
getUnflushedMarkers
- Specified by:
getUnflushedMarkersin interfaceISqlTransaction
-
getConnection
-
allowInsertIntoAutoIncrementColumns
public void allowInsertIntoAutoIncrementColumns(boolean value, Table table, String quote, String catalogSeparator, String schemaSepartor) Description copied from interface:ISqlTransactionIndicate that the current session is to allow updates to columns that have been marked as auto increment. This is specific to SQL Server.- Specified by:
allowInsertIntoAutoIncrementColumnsin interfaceISqlTransaction
-
insertWithGeneratedKey
public long insertWithGeneratedKey(String sql, String column, String sequenceName, Object[] args, int[] types) - Specified by:
insertWithGeneratedKeyin interfaceISqlTransaction
-
getLogSqlBuilder
-
setLogSqlBuilder
-
clearBatch
public void clearBatch()- Specified by:
clearBatchin interfaceISqlTransaction
-
isAllowInsertIntoAutoIncrement
public boolean isAllowInsertIntoAutoIncrement()- Specified by:
isAllowInsertIntoAutoIncrementin interfaceISqlTransaction
-