|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.midao.jdbc.core.AbstractQueryRunner
public abstract class AbstractQueryRunner
Core of QueryRunner implementation.
Field Summary | |
---|---|
protected Overrider |
overrider
|
Method Summary | ||
---|---|---|
protected int[] |
batch(StatementHandler stmtHandler,
java.lang.String sql,
QueryParameters[] params)
Execute a batch of SQL INSERT, UPDATE, or DELETE queries. |
|
protected
|
call(StatementHandler stmtHandler,
java.lang.String sql,
QueryParameters params,
OutputHandler<T> outputHandler)
Executes the given CALL SQL statement. |
|
void |
commit()
Commits current Transaction Usable only when QueryRunnerService.setTransactionManualMode(boolean) set as true |
|
protected QueryInputHandler |
convertToQueryInputHandler(AbstractNamedInputHandler inputHandler,
java.lang.String catalog,
java.lang.String schema,
boolean useCache)
Uses MetadataHandler to read Stored Procedure/Function parameters and creates new
QueryInputHandler instance with parameter values from @inputHandler |
|
protected java.sql.Statement |
createStatement(java.sql.Connection conn,
java.lang.String sql)
Creates new Statement instance |
|
ExceptionHandler |
getExceptionHandler()
Returns assigned exception handler |
|
MetadataHandler |
getMetadataHandler()
Returns MetadataHandler implementation assigned to this QueryRunnerService instance |
|
Overrider |
getOverrider()
Returns Overrider instance assigned to this QueryRunnerService instance |
|
protected QueryParameters[] |
getQueryParams(InputHandler[] inputHandlers)
Reads array of InputHandler and returns array of parameter values
Used during batch invocation |
|
protected QueryParameters[] |
getQueryParams(java.lang.Object[][] params)
Converts array of parameter values (as array) and converts it into array of QueryParameters
Used during batch invocation |
|
protected java.lang.String |
getSqlQuery(InputHandler[] inputHandlers)
Reads array of InputHandler and checks if they have one query string. |
|
StatementHandler |
getStatementHandler()
Returns StatementHandler implementation assigned to this QueryRunnerService instance |
|
TransactionHandler |
getTransactionHandler()
Returns TransactionHandler implementation assigned to this QueryRunnerService instance |
|
java.lang.Integer |
getTransactionIsolationLevel()
Returns current Transaction Isolation level |
|
TypeHandler |
getTypeHandler()
Returns TypeHandler implementation assigned to this QueryRunnerService instance |
|
boolean |
isTransactionManualMode()
Returns current Transaction mode |
|
protected java.sql.SQLException |
nullException()
Returns new SQLException instance. |
|
QueryRunnerService |
override(java.lang.String operation,
java.lang.Object value)
Adds override which would be used until removed. |
|
QueryRunnerService |
overrideOnce(java.lang.String operation,
java.lang.Object value)
Adds override which would be used only once. |
|
protected java.sql.CallableStatement |
prepareCall(java.sql.Connection conn,
java.lang.String sql)
Creates new CallableStatement instance |
|
protected java.sql.PreparedStatement |
prepareStatement(java.sql.Connection conn,
java.lang.String sql,
boolean getGeneratedKeys)
Creates new PreparedStatement instance |
|
protected
|
query(StatementHandler stmtHandler,
java.lang.String sql,
OutputHandler<T> outputHandler,
QueryParameters params)
Executes the given SELECT SQL query and returns a result object. |
|
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Removes the specified Savepoint and subsequent Savepoint objects from the current transaction. |
|
QueryRunnerService |
removeOverride(java.lang.String operation)
Removes override. |
|
void |
rollback()
Rollbacks current Transaction Usable only when QueryRunnerService.setTransactionManualMode(boolean) set as true |
|
void |
rollback(java.sql.Savepoint savepoint)
Undoes all changes made after the given Savepoint object was set. |
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Allows assigning exception handler |
|
void |
setMetadataHandler(MetadataHandler metadataHandler)
Assigns MetadataHandler implementation to this QueryRunnerService instance
Please be aware that input MetadataHandler should be share same Overrider instance:
Example: QueryRunner.setMetadataHandler(new BaseMetadataHandler(queryRunner.getOverrider())); |
|
java.sql.Savepoint |
setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. |
|
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. |
|
void |
setStatementHandler(StatementHandler statementHandler)
Assigns StatementHandler implementation to this QueryRunnerService instance
Please be aware that input StatementHandler should be share same Overrider instance:
Example: QueryRunner.setStatementHandler(new BaseStatementHandler(queryRunner.getOverrider())); |
|
void |
setTransactionHandler(TransactionHandler transactionHandler)
Assigns TransactionHandler implementation to this QueryRunnerService instance
Please be aware that input TransactionHandler should be share same Overrider instance:
Example: QueryRunner.setTransactionHandler(new BaseTransactionHandler(queryRunner.getOverrider())); |
|
void |
setTransactionIsolationLevel(java.lang.Integer level)
Transaction Isolation level. |
|
void |
setTransactionManualMode(boolean manualMode)
Sets Transaction mode. |
|
void |
setTypeHandler(TypeHandler typeHandler)
Assigns TypeHandler implementation to this QueryRunnerService instance
Please be aware that input TypeHandler should be share same Overrider instance:
Example: QueryRunner.setTypeHandler(new BaseTypeHandler(queryRunner.getOverrider())); |
|
protected
|
update(StatementHandler stmtHandler,
java.lang.String sql,
OutputHandler<T> outputHandler,
QueryParameters params)
Executes the given INSERT, UPDATE, or DELETE SQL statement without any replacement parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.midao.jdbc.core.service.QueryRunnerService |
---|
batch, batch, call, call, call, call, call, query, query, query, update, update, update, update, update, update |
Field Detail |
---|
protected final Overrider overrider
Method Detail |
---|
public boolean isTransactionManualMode()
isTransactionManualMode
in interface QueryRunnerService
public void setTransactionManualMode(boolean manualMode)
QueryRunnerService.commit()
is required.
setTransactionManualMode
in interface QueryRunnerService
manualMode
- manual modepublic void setTransactionIsolationLevel(java.lang.Integer level)
setTransactionIsolationLevel
in interface QueryRunnerService
level
- Transaction Isolation levelpublic java.lang.Integer getTransactionIsolationLevel()
getTransactionIsolationLevel
in interface QueryRunnerService
public void commit() throws java.sql.SQLException
QueryRunnerService.setTransactionManualMode(boolean)
set as true
commit
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic void rollback() throws java.sql.SQLException
QueryRunnerService.setTransactionManualMode(boolean)
set as true
rollback
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic java.sql.Savepoint setSavepoint() throws java.sql.SQLException
Connection.setSavepoint()
Usable only when QueryRunnerService.setTransactionManualMode(boolean)
set as true
setSavepoint
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
Connection.setSavepoint(String)
Usable only when QueryRunnerService.setTransactionManualMode(boolean)
set as true
setSavepoint
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
Connection.rollback(java.sql.Savepoint)
Usable only when QueryRunnerService.setTransactionManualMode(boolean)
set as true
rollback
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
Connection.releaseSavepoint(java.sql.Savepoint)
Usable only when QueryRunnerService.setTransactionManualMode(boolean)
set as true
releaseSavepoint
in interface QueryRunnerService
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic QueryRunnerService overrideOnce(java.lang.String operation, java.lang.Object value)
MidaoConstants
OVERRIDE_* Constants
overrideOnce
in interface QueryRunnerService
operation
- name of the operationvalue
- override value
public QueryRunnerService override(java.lang.String operation, java.lang.Object value)
MidaoConstants
OVERRIDE_* Constants
override
in interface QueryRunnerService
operation
- name of the operationvalue
- override value
public QueryRunnerService removeOverride(java.lang.String operation)
MidaoConstants
OVERRIDE_* Constants
removeOverride
in interface QueryRunnerService
operation
- name of the operation
public TypeHandler getTypeHandler()
TypeHandler
implementation assigned to this QueryRunnerService
instance
TypeHandler
implementation assigned to this QueryRunnerService
instancepublic void setTypeHandler(TypeHandler typeHandler)
TypeHandler
implementation to this QueryRunnerService
instance
Please be aware that input TypeHandler
should be share same Overrider
instance:
Example: QueryRunner.setTypeHandler(new BaseTypeHandler(queryRunner.getOverrider()));
typeHandler
- TypeHandler
implementationpublic TransactionHandler getTransactionHandler()
TransactionHandler
implementation assigned to this QueryRunnerService
instance
TransactionHandler
implementation assigned to this QueryRunnerService
instancepublic void setTransactionHandler(TransactionHandler transactionHandler)
TransactionHandler
implementation to this QueryRunnerService
instance
Please be aware that input TransactionHandler
should be share same Overrider
instance:
Example: QueryRunner.setTransactionHandler(new BaseTransactionHandler(queryRunner.getOverrider()));
transactionHandler
- TransactionHandler
implementationpublic StatementHandler getStatementHandler()
StatementHandler
implementation assigned to this QueryRunnerService
instance
StatementHandler
implementation assigned to this QueryRunnerService
instancepublic void setStatementHandler(StatementHandler statementHandler)
StatementHandler
implementation to this QueryRunnerService
instance
Please be aware that input StatementHandler
should be share same Overrider
instance:
Example: QueryRunner.setStatementHandler(new BaseStatementHandler(queryRunner.getOverrider()));
statementHandler
- StatementHandler
implementationpublic MetadataHandler getMetadataHandler()
MetadataHandler
implementation assigned to this QueryRunnerService
instance
MetadataHandler
implementation assigned to this QueryRunnerService
instancepublic void setMetadataHandler(MetadataHandler metadataHandler)
MetadataHandler
implementation to this QueryRunnerService
instance
Please be aware that input MetadataHandler
should be share same Overrider
instance:
Example: QueryRunner.setMetadataHandler(new BaseMetadataHandler(queryRunner.getOverrider()));
metadataHandler
- MetadataHandler
implementationpublic Overrider getOverrider()
Overrider
instance assigned to this QueryRunnerService
instance
Overrider
instance assigned to this QueryRunnerService
instanceprotected java.sql.Statement createStatement(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLException
Statement
instance
conn
- SQL Connectionsql
- SQL Query string
Statement
instance
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected java.sql.PreparedStatement prepareStatement(java.sql.Connection conn, java.lang.String sql, boolean getGeneratedKeys) throws java.sql.SQLException
PreparedStatement
instance
conn
- SQL Connectionsql
- SQL Query stringgetGeneratedKeys
- specifies if generated keys should be returned
PreparedStatement
instance
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected java.sql.CallableStatement prepareCall(java.sql.Connection conn, java.lang.String sql) throws java.sql.SQLException
CallableStatement
instance
conn
- SQL Connectionsql
- SQL Query string
CallableStatement
instance
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected java.sql.SQLException nullException()
SQLException
instance.
Used to throw exception during input arguments null check
SQLException
instanceprotected int[] batch(StatementHandler stmtHandler, java.lang.String sql, QueryParameters[] params) throws java.sql.SQLException
stmtHandler
- StatementHandler
implementationsql
- The SQL query to execute.params
- An array of query replacement parameters. Each row in
this array is one set of batch replacement values.
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected <T> T query(StatementHandler stmtHandler, java.lang.String sql, OutputHandler<T> outputHandler, QueryParameters params) throws java.sql.SQLException
T
- The type of object that the handler returnsstmtHandler
- StatementHandler
implementationsql
- The SQL query to execute.outputHandler
- OutputHandler
implementationparams
- parameter values
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected <T> T update(StatementHandler stmtHandler, java.lang.String sql, OutputHandler<T> outputHandler, QueryParameters params) throws java.sql.SQLException
T
- The type of object that the handler returnsstmtHandler
- StatementHandler
implementationsql
- The SQL query to execute.outputHandler
- OutputHandler
implementationparams
- parameter values
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected <T> QueryParameters call(StatementHandler stmtHandler, java.lang.String sql, QueryParameters params, OutputHandler<T> outputHandler) throws java.sql.SQLException
stmtHandler
- StatementHandler
implementationsql
- The SQL query to execute.params
- parameter valuesoutputHandler
- OutputHandler
implementation
QueryParameters.getReturn()
java.sql.SQLException
- if exception would be thrown by Driver/Databaseprotected java.lang.String getSqlQuery(InputHandler[] inputHandlers) throws java.sql.SQLException
InputHandler
and checks if they have one query string.
Used during batch invocation
inputHandlers
- array of InputHandler
java.sql.SQLException
- if SQL Query string is not the same among whole array of InputHandler
protected QueryParameters[] getQueryParams(InputHandler[] inputHandlers)
InputHandler
and returns array of parameter values
Used during batch invocation
inputHandlers
- array of InputHandler
protected QueryParameters[] getQueryParams(java.lang.Object[][] params)
QueryParameters
Used during batch invocation
params
-
protected QueryInputHandler convertToQueryInputHandler(AbstractNamedInputHandler inputHandler, java.lang.String catalog, java.lang.String schema, boolean useCache) throws java.sql.SQLException
MetadataHandler
to read Stored Procedure/Function parameters and creates new
QueryInputHandler
instance with parameter values from @inputHandler
inputHandler
- AbstractNamedInputHandler
which used as source for QueryInputHandler
parameter valuescatalog
- Database Catalogschema
- Database SchemauseCache
- specifies if MetadataHandler
should use cache
QueryInputHandler
instance with values from @inputHandler
java.sql.SQLException
- if exception would be thrown by Driver/Databasepublic ExceptionHandler getExceptionHandler()
public void setExceptionHandler(ExceptionHandler exceptionHandler)
exceptionHandler
- new exception handler which should be used by this instance of QueryRunner
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |