|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface Handle
This represents a connection to the database system. It ususally is a wrapper around a JDBC Connection object.
| Method Summary | ||
|---|---|---|
|
attach(Class<SqlObjectType> sqlObjectType)
Create a a sql object of the specified type bound to this handle. |
|
Handle |
begin()
Start a transaction |
|
Handle |
checkpoint(String name)
Create a transaction checkpoint (savepoint in JDBC terminology) with the name provided. |
|
void |
close()
|
|
Handle |
commit()
Commit a transaction |
|
Batch |
createBatch()
Create a non-prepared (no bound parameters, but different SQL, batch statement |
|
Call |
createCall(String callableSql)
Create a call to a stored procedure |
|
Query<Map<String,Object>> |
createQuery(String sql)
Return a default Query instance which can be executed later, as long as this handle remains open. |
|
Script |
createScript(String name)
Creates an SQL script, looking for the source of the script using the current statement locator (which defaults to searching the classpath) |
|
Update |
createStatement(String sql)
Create an Insert or Update statement which returns the number of rows modified. |
|
void |
define(String key,
Object value)
Define a statement attribute which will be applied to all StatementContext
instances for statements created from this handle |
|
void |
execute(String sql,
Object... args)
Execute some SQL with no return value |
|
Connection |
getConnection()
Get the JDBC Connection this Handle uses |
|
TransactionIsolationLevel |
getTransactionIsolationLevel()
Obtain the current transaction isolation level |
|
int |
insert(String sql,
Object... args)
Execute a simple insert statement |
|
|
inTransaction(TransactionCallback<ReturnType> callback)
Executes callback in a transaction. |
|
|
inTransaction(TransactionIsolationLevel level,
TransactionCallback<ReturnType> callback)
Executes callback in a transaction. |
|
boolean |
isInTransaction()
Is the handle in a transaction? It defers to the underlying TransactionHandler |
|
PreparedBatch |
prepareBatch(String sql)
Prepare a batch to execute. |
|
void |
registerMapper(ResultSetMapper mapper)
Register a result set mapper which will have its parameterized type inspected to determine what it maps to Will be used with Query.mapTo(Class) for registered mappings. |
|
void |
registerMapper(ResultSetMapperFactory factory)
Register a result set mapper factory. |
|
Handle |
release(String checkpointName)
Release a previously created checkpoint |
|
Handle |
rollback()
Rollback a transaction |
|
Handle |
rollback(String checkpointName)
Rollback a transaction to a named checkpoint |
|
List<Map<String,Object>> |
select(String sql,
Object... args)
Convenience method which executes a select with purely positional arguments |
|
void |
setSQLLog(SQLLog log)
Specify the class used to log sql statements. |
|
void |
setStatementBuilder(StatementBuilder builder)
Specify the statement builder to use for this handle |
|
void |
setStatementLocator(StatementLocator locator)
Allows for overiding the default statement locator. |
|
void |
setStatementRewriter(StatementRewriter rewriter)
Allows for overiding the default statement rewriter. |
|
void |
setTimingCollector(TimingCollector timingCollector)
Specify the class used to collect timing information. |
|
void |
setTransactionIsolation(int level)
Set the transaction isolation level on the underlying connection |
|
void |
setTransactionIsolation(TransactionIsolationLevel level)
Set the transaction isolation level on the underlying connection |
|
int |
update(String sql,
Object... args)
Execute a simple update statement |
|
| Method Detail |
|---|
<SqlObjectType> SqlObjectType attach(Class<SqlObjectType> sqlObjectType)
SqlObjectType - sqlObjectType -
Handle begin()
Handle checkpoint(String name)
name - The name of the checkpoint
void close()
UnableToCloseResourceException - if any
resources throw exception while closingHandle commit()
Batch createBatch()
prepareBatch(String)Call createCall(String callableSql)
callableSql -
Query<Map<String,Object>> createQuery(String sql)
sql - the select sqlScript createScript(String name)
Update createStatement(String sql)
sql - The statement sql
void define(String key,
Object value)
StatementContext
instances for statements created from this handle
key - Attribute namevalue - Attribute value
void execute(String sql,
Object... args)
sql - the sql to executeargs - arguments to bind to the sqlConnection getConnection()
TransactionIsolationLevel getTransactionIsolationLevel()
int insert(String sql,
Object... args)
sql - the insert SQL
<ReturnType> ReturnType inTransaction(TransactionCallback<ReturnType> callback)
throws TransactionFailedException
callback in a transaction. If the transaction succeeds, the
result of the callback will be returned. If it fails a TransactionFailedException
will be thrown.
TransactionFailedException - if the transaction failed in the callback
<ReturnType> ReturnType inTransaction(TransactionIsolationLevel level,
TransactionCallback<ReturnType> callback)
throws TransactionFailedException
callback in a transaction. If the transaction succeeds, the
result of the callback will be returned. If it fails a TransactionFailedException
will be thrown.
This form accepts a transaction isolation level which will be applied to the connection for the scope of this transaction, after which the original isolation level will be restored.
TransactionFailedException - if the transaction failed in the callbackboolean isInTransaction()
TransactionHandler
PreparedBatch prepareBatch(String sql)
sql - the batch SQL
void registerMapper(ResultSetMapper mapper)
Query.mapTo(Class) for registered mappings.
void registerMapper(ResultSetMapperFactory factory)
Query.mapTo(Class) for registerd mappings.
Handle release(String checkpointName)
checkpointName - the name of the checkpoint to releaseHandle rollback()
Handle rollback(String checkpointName)
checkpointName - the name of the checkpoint, previously declared with checkpoint(java.lang.String)
List<Map<String,Object>> select(String sql,
Object... args)
sql - SQL or named statementargs - arguments to bind positionally
void setSQLLog(SQLLog log)
void setStatementBuilder(StatementBuilder builder)
builder - StatementBuilder to be usedvoid setStatementLocator(StatementLocator locator)
void setStatementRewriter(StatementRewriter rewriter)
void setTimingCollector(TimingCollector timingCollector)
void setTransactionIsolation(int level)
level - the isolation level to usevoid setTransactionIsolation(TransactionIsolationLevel level)
level - the isolation level to use
int update(String sql,
Object... args)
sql - the update SQLargs - positional arguments
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||