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 boolean
protected int
protected Connection
protected boolean
protected JdbcSqlTemplate
protected List<ISqlTransactionListener>
protected LogSqlBuilder
protected boolean
protected String
protected PreparedStatement
-
Constructor Summary
ConstructorsConstructorDescriptionJdbcSqlTransaction
(JdbcSqlTemplate jdbcSqlTemplate) JdbcSqlTransaction
(JdbcSqlTemplate jdbcSqlTemplate, boolean autoCommit) -
Method Summary
Modifier and TypeMethodDescriptionint
void
void
allowInsertIntoAutoIncrementColumns
(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.void
void
close()
void
commit()
int
protected int
executeAllowingResults
(PreparedStatement preparedStatement) <T> T
executeCallback
(IConnectionCallback<T> callback) protected int
executePreparedUpdate
(PreparedStatement preparedStatement, String sql, Object[] args, int[] argTypes) int
flush()
int
getUnflushedMarkers
(boolean clear) protected final void
init()
long
insertWithGeneratedKey
(String sql, String column, String sequenceName, Object[] args, int[] types) boolean
boolean
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.void
Each time the SQL changes it needs to be submitted for preparationint
prepareAndExecute
(String sql, Object... args) int
prepareAndExecute
(String sql, Object[] args, int[] types) int
prepareAndExecute
(String sql, Map<String, Object> args) <T> List<T>
query
(String sql, ISqlRowMapper<T> mapper, Object[] args, int[] types) <T> List<T>
int
queryForInt
(String sql, Object... args) long
queryForLong
(String sql, Object... args) <T> T
queryForObject
(String sql, Class<T> clazz, Object... args) queryForRow
(String sql, Object... args) protected void
void
rollback()
protected void
rollback
(boolean clearMarkers) void
setBatchSize
(int batchSize) void
setInBatchMode
(boolean useBatching) void
setLogSqlBuilder
(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:
addSqlTransactionListener
in interfaceISqlTransaction
-
init
protected final void init() -
setInBatchMode
public void setInBatchMode(boolean useBatching) - Specified by:
setInBatchMode
in interfaceISqlTransaction
-
isInBatchMode
public boolean isInBatchMode()- Specified by:
isInBatchMode
in interfaceISqlTransaction
-
commit
public void commit()- Specified by:
commit
in interfaceISqlTransaction
-
rollback
public void rollback()- Specified by:
rollback
in interfaceISqlTransaction
-
rollback
protected void rollback(boolean clearMarkers) -
close
public void close()- Specified by:
close
in interfaceISqlTransaction
-
flush
public int flush()- Specified by:
flush
in interfaceISqlTransaction
-
queryForRow
- Specified by:
queryForRow
in interfaceISqlTransaction
-
queryForInt
- Specified by:
queryForInt
in interfaceISqlTransaction
-
queryForLong
- Specified by:
queryForLong
in interfaceISqlTransaction
-
queryForObject
- Specified by:
queryForObject
in interfaceISqlTransaction
-
query
- Specified by:
query
in interfaceISqlTransaction
-
query
- Specified by:
query
in interfaceISqlTransaction
-
execute
- Specified by:
execute
in interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecute
in interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecute
in interfaceISqlTransaction
-
prepareAndExecute
- Specified by:
prepareAndExecute
in 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:ISqlTransaction
Each time the SQL changes it needs to be submitted for preparation- Specified by:
prepare
in interfaceISqlTransaction
-
addRow
- Specified by:
addRow
in 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:
getUnflushedMarkers
in interfaceISqlTransaction
-
getConnection
-
allowInsertIntoAutoIncrementColumns
public void allowInsertIntoAutoIncrementColumns(boolean value, Table table, String quote, String catalogSeparator, String schemaSepartor) Description copied from interface:ISqlTransaction
Indicate 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:
allowInsertIntoAutoIncrementColumns
in interfaceISqlTransaction
-
insertWithGeneratedKey
public long insertWithGeneratedKey(String sql, String column, String sequenceName, Object[] args, int[] types) - Specified by:
insertWithGeneratedKey
in interfaceISqlTransaction
-
getLogSqlBuilder
-
setLogSqlBuilder
-
clearBatch
public void clearBatch()- Specified by:
clearBatch
in interfaceISqlTransaction
-
isAllowInsertIntoAutoIncrement
public boolean isAllowInsertIntoAutoIncrement()- Specified by:
isAllowInsertIntoAutoIncrement
in interfaceISqlTransaction
-