com.ibatis.sqlmap.engine.impl
Class SqlMapExecutorDelegate

java.lang.Object
  extended bycom.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate

public class SqlMapExecutorDelegate
extends java.lang.Object

The workhorse that really runs the SQL


Field Summary
static int DEFAULT_MAX_REQUESTS
          The default maximum number of requests
static int DEFAULT_MAX_SESSIONS
          The default maximum number of sessions
static int DEFAULT_MAX_TRANSACTIONS
          The default maximum number of transactions
protected  SqlExecutor sqlExecutor
           
 
Constructor Summary
SqlMapExecutorDelegate()
          Default constructor
 
Method Summary
 void addCacheModel(CacheModel model)
          Add a cache model
 void addMappedStatement(MappedStatement ms)
          Add a mapped statement
 void addParameterMap(ParameterMap map)
          Add a parameter map
 void addResultMap(ResultMap map)
          Add a result map
protected  void autoCommitTransaction(SessionScope session, boolean autoStart)
           
protected  void autoEndTransaction(SessionScope session, boolean autoStart)
           
protected  Transaction autoStartTransaction(SessionScope session, boolean autoStart, Transaction trans)
           
 void commitTransaction(SessionScope session)
          Commit the transaction on a session
 int delete(SessionScope session, java.lang.String id, java.lang.Object param)
          Execute a delete statement
 void endTransaction(SessionScope session)
          End the transaction on a session
 boolean equals(java.lang.Object obj)
           
 int executeBatch(SessionScope session)
          Execute a batch for a session
 java.util.List executeBatchDetailed(SessionScope session)
          Execute a batch for a session
 void flushDataCache()
          Flush all of the data caches
 void flushDataCache(java.lang.String id)
          Flush a single cache by ID
 CacheModel getCacheModel(java.lang.String id)
          Get a cache model by ID
 java.util.Iterator getCacheModelNames()
          Get an iterator of the cache models
 DataExchangeFactory getDataExchangeFactory()
          Getter for the DataExchangeFactory
 javax.sql.DataSource getDataSource()
          Get the DataSource for the session
 MappedStatement getMappedStatement(java.lang.String id)
          Get a mappedstatement by its ID
 java.util.Iterator getMappedStatementNames()
          Get an iterator of the mapped statements
 int getMaxRequests()
          Getter for the maximum number of requests
 int getMaxSessions()
          Getter for the maximum number of sessions
 int getMaxTransactions()
          Getter for the the maximum number of transactions
 ParameterMap getParameterMap(java.lang.String id)
          Get a parameter map by ID
 java.util.Iterator getParameterMapNames()
          Get an iterator of all of the parameter maps
 ResultMap getResultMap(java.lang.String id)
          Get a result map by ID
 java.util.Iterator getResultMapNames()
          Get an iterator of the result maps
 ResultObjectFactory getResultObjectFactory()
           
 SqlExecutor getSqlExecutor()
          Getter for the SqlExecutor
 Transaction getTransaction(SessionScope session)
          Get a transaction for the session
 TransactionManager getTxManager()
          Getter for the transaction manager
 TypeHandlerFactory getTypeHandlerFactory()
          Getter for the TypeHandlerFactory
 int hashCode()
           
 java.lang.Object insert(SessionScope session, java.lang.String id, java.lang.Object param)
          Call an insert statement by ID
 boolean isCacheModelsEnabled()
          Getter for the status of caching
 boolean isEnhancementEnabled()
          Getter for the status of CGLib enhancements
 boolean isLazyLoadingEnabled()
          Getter for the status of lazy loading
protected  RequestScope popRequest(SessionScope session, MappedStatement mappedStatement)
           
protected  SessionScope popSession()
           
protected  void pushRequest(RequestScope request)
           
protected  void pushSession(SessionScope session)
           
 java.util.List queryForList(SessionScope session, java.lang.String id, java.lang.Object paramObject)
          Execute a query for a list
 java.util.List queryForList(SessionScope session, java.lang.String id, java.lang.Object paramObject, int skip, int max)
          Execute a query for a list
 java.util.Map queryForMap(SessionScope session, java.lang.String id, java.lang.Object paramObject, java.lang.String keyProp)
          Execute a query for a map.
 java.util.Map queryForMap(SessionScope session, java.lang.String id, java.lang.Object paramObject, java.lang.String keyProp, java.lang.String valueProp)
          Execute a query for a map.
 java.lang.Object queryForObject(SessionScope session, java.lang.String id, java.lang.Object paramObject)
          Execute a select for a single object
 java.lang.Object queryForObject(SessionScope session, java.lang.String id, java.lang.Object paramObject, java.lang.Object resultObject)
          Execute a select for a single object
 PaginatedList queryForPaginatedList(SessionScope session, java.lang.String id, java.lang.Object paramObject, int pageSize)
          Execute a query and return a paginated list
 void queryWithRowHandler(SessionScope session, java.lang.String id, java.lang.Object paramObject, RowHandler rowHandler)
          Execute a query with a row handler.
 void setCacheModelsEnabled(boolean cacheModelsEnabled)
          Turn on or off caching
 void setEnhancementEnabled(boolean enhancementEnabled)
          Turn on or off CGLib enhancements
 void setLazyLoadingEnabled(boolean lazyLoadingEnabled)
          Turn on or off lazy loading
 void setMaxRequests(int maxRequests)
          Setter for the maximum number of requests
 void setMaxSessions(int maxSessions)
          Setter for the maximum number of sessions
 void setMaxTransactions(int maxTransactions)
          Setter for the maximum number of transactions
 void setResultObjectFactory(ResultObjectFactory resultObjectFactory)
           
 void setTxManager(TransactionManager txManager)
          Setter for the transaction manager
 void setUserProvidedTransaction(SessionScope session, java.sql.Connection userConnection)
          Use a user-provided transaction for a session
 void startBatch(SessionScope session)
          Start a batch for a session
 void startTransaction(SessionScope session)
          Start a transaction on the session
 void startTransaction(SessionScope session, int transactionIsolation)
          Start a transaction on the session with the specified isolation level.
 int update(SessionScope session, java.lang.String id, java.lang.Object param)
          Execute an update statement
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_REQUESTS

public static final int DEFAULT_MAX_REQUESTS
The default maximum number of requests

See Also:
Constant Field Values

DEFAULT_MAX_SESSIONS

public static final int DEFAULT_MAX_SESSIONS
The default maximum number of sessions

See Also:
Constant Field Values

DEFAULT_MAX_TRANSACTIONS

public static final int DEFAULT_MAX_TRANSACTIONS
The default maximum number of transactions

See Also:
Constant Field Values

sqlExecutor

protected SqlExecutor sqlExecutor
Constructor Detail

SqlMapExecutorDelegate

public SqlMapExecutorDelegate()
Default constructor

Method Detail

getDataExchangeFactory

public DataExchangeFactory getDataExchangeFactory()
Getter for the DataExchangeFactory

Returns:
- the DataExchangeFactory

getTypeHandlerFactory

public TypeHandlerFactory getTypeHandlerFactory()
Getter for the TypeHandlerFactory

Returns:
- the TypeHandlerFactory

isLazyLoadingEnabled

public boolean isLazyLoadingEnabled()
Getter for the status of lazy loading

Returns:
- the status

setLazyLoadingEnabled

public void setLazyLoadingEnabled(boolean lazyLoadingEnabled)
Turn on or off lazy loading

Parameters:
lazyLoadingEnabled - - the new state of caching

isCacheModelsEnabled

public boolean isCacheModelsEnabled()
Getter for the status of caching

Returns:
- the status

setCacheModelsEnabled

public void setCacheModelsEnabled(boolean cacheModelsEnabled)
Turn on or off caching

Parameters:
cacheModelsEnabled - - the new state of caching

isEnhancementEnabled

public boolean isEnhancementEnabled()
Getter for the status of CGLib enhancements

Returns:
- the status

setEnhancementEnabled

public void setEnhancementEnabled(boolean enhancementEnabled)
Turn on or off CGLib enhancements

Parameters:
enhancementEnabled - - the new state

getMaxRequests

public int getMaxRequests()
Getter for the maximum number of requests

Returns:
- the maximum number of requests

setMaxRequests

public void setMaxRequests(int maxRequests)
Setter for the maximum number of requests

Parameters:
maxRequests - - the maximum number of requests

getMaxSessions

public int getMaxSessions()
Getter for the maximum number of sessions

Returns:
- the maximum number of sessions

setMaxSessions

public void setMaxSessions(int maxSessions)
Setter for the maximum number of sessions

Parameters:
maxSessions - - the maximum number of sessions

getMaxTransactions

public int getMaxTransactions()
Getter for the the maximum number of transactions

Returns:
- the maximum number of transactions

setMaxTransactions

public void setMaxTransactions(int maxTransactions)
Setter for the maximum number of transactions

Parameters:
maxTransactions - - the maximum number of transactions

getTxManager

public TransactionManager getTxManager()
Getter for the transaction manager

Returns:
- the transaction manager

setTxManager

public void setTxManager(TransactionManager txManager)
Setter for the transaction manager

Parameters:
txManager - - the transaction manager

addMappedStatement

public void addMappedStatement(MappedStatement ms)
Add a mapped statement

Parameters:
ms - - the mapped statement to add

getMappedStatementNames

public java.util.Iterator getMappedStatementNames()
Get an iterator of the mapped statements

Returns:
- the iterator

getMappedStatement

public MappedStatement getMappedStatement(java.lang.String id)
Get a mappedstatement by its ID

Parameters:
id - - the statement ID
Returns:
- the mapped statement

addCacheModel

public void addCacheModel(CacheModel model)
Add a cache model

Parameters:
model - - the model to add

getCacheModelNames

public java.util.Iterator getCacheModelNames()
Get an iterator of the cache models

Returns:
- the cache models

getCacheModel

public CacheModel getCacheModel(java.lang.String id)
Get a cache model by ID

Parameters:
id - - the ID
Returns:
- the cache model

addResultMap

public void addResultMap(ResultMap map)
Add a result map

Parameters:
map - - the result map to add

getResultMapNames

public java.util.Iterator getResultMapNames()
Get an iterator of the result maps

Returns:
- the result maps

getResultMap

public ResultMap getResultMap(java.lang.String id)
Get a result map by ID

Parameters:
id - - the ID
Returns:
- the result map

addParameterMap

public void addParameterMap(ParameterMap map)
Add a parameter map

Parameters:
map - - the map to add

getParameterMapNames

public java.util.Iterator getParameterMapNames()
Get an iterator of all of the parameter maps

Returns:
- the parameter maps

getParameterMap

public ParameterMap getParameterMap(java.lang.String id)
Get a parameter map by ID

Parameters:
id - - the ID
Returns:
- the parameter map

flushDataCache

public void flushDataCache()
Flush all of the data caches


flushDataCache

public void flushDataCache(java.lang.String id)
Flush a single cache by ID

Parameters:
id - - the ID

insert

public java.lang.Object insert(SessionScope session,
                               java.lang.String id,
                               java.lang.Object param)
                        throws java.sql.SQLException
Call an insert statement by ID

Parameters:
session - - the session
id - - the statement ID
param - - the parameter object
Returns:
- the generated key (or null)
Throws:
java.sql.SQLException - - if the insert fails

update

public int update(SessionScope session,
                  java.lang.String id,
                  java.lang.Object param)
           throws java.sql.SQLException
Execute an update statement

Parameters:
session - - the session scope
id - - the statement ID
param - - the parameter object
Returns:
- the number of rows updated
Throws:
java.sql.SQLException - - if the update fails

delete

public int delete(SessionScope session,
                  java.lang.String id,
                  java.lang.Object param)
           throws java.sql.SQLException
Execute a delete statement

Parameters:
session - - the session scope
id - - the statement ID
param - - the parameter object
Returns:
- the number of rows deleted
Throws:
java.sql.SQLException - - if the delete fails

queryForObject

public java.lang.Object queryForObject(SessionScope session,
                                       java.lang.String id,
                                       java.lang.Object paramObject)
                                throws java.sql.SQLException
Execute a select for a single object

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
Returns:
- the result of the query
Throws:
java.sql.SQLException - - if the query fails

queryForObject

public java.lang.Object queryForObject(SessionScope session,
                                       java.lang.String id,
                                       java.lang.Object paramObject,
                                       java.lang.Object resultObject)
                                throws java.sql.SQLException
Execute a select for a single object

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
resultObject - - the result object (if not supplied or null, a new object will be created)
Returns:
- the result of the query
Throws:
java.sql.SQLException - - if the query fails

queryForList

public java.util.List queryForList(SessionScope session,
                                   java.lang.String id,
                                   java.lang.Object paramObject)
                            throws java.sql.SQLException
Execute a query for a list

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
Returns:
- the data list
Throws:
java.sql.SQLException - - if the query fails

queryForList

public java.util.List queryForList(SessionScope session,
                                   java.lang.String id,
                                   java.lang.Object paramObject,
                                   int skip,
                                   int max)
                            throws java.sql.SQLException
Execute a query for a list

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
skip - - the number of rows to skip
max - - the maximum number of rows to return
Returns:
- the data list
Throws:
java.sql.SQLException - - if the query fails

queryWithRowHandler

public void queryWithRowHandler(SessionScope session,
                                java.lang.String id,
                                java.lang.Object paramObject,
                                RowHandler rowHandler)
                         throws java.sql.SQLException
Execute a query with a row handler. The row handler is called once per row in the query results.

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
rowHandler - - the row handler
Throws:
java.sql.SQLException - - if the query fails

queryForPaginatedList

public PaginatedList queryForPaginatedList(SessionScope session,
                                           java.lang.String id,
                                           java.lang.Object paramObject,
                                           int pageSize)
                                    throws java.sql.SQLException
Execute a query and return a paginated list

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
pageSize - - the page size
Returns:
- the data list
Throws:
java.sql.SQLException - - if the query fails

queryForMap

public java.util.Map queryForMap(SessionScope session,
                                 java.lang.String id,
                                 java.lang.Object paramObject,
                                 java.lang.String keyProp)
                          throws java.sql.SQLException
Execute a query for a map. The map has the table key as the key, and the results as the map data

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
keyProp - - the key property (from the results for the map)
Returns:
- the Map
Throws:
java.sql.SQLException - - if the query fails

queryForMap

public java.util.Map queryForMap(SessionScope session,
                                 java.lang.String id,
                                 java.lang.Object paramObject,
                                 java.lang.String keyProp,
                                 java.lang.String valueProp)
                          throws java.sql.SQLException
Execute a query for a map. The map has the table key as the key, and a property from the results as the map data

Parameters:
session - - the session scope
id - - the statement ID
paramObject - - the parameter object
keyProp - - the property for the map key
valueProp - - the property for the map data
Returns:
- the Map
Throws:
java.sql.SQLException - - if the query fails

startTransaction

public void startTransaction(SessionScope session)
                      throws java.sql.SQLException
Start a transaction on the session

Parameters:
session - - the session
Throws:
java.sql.SQLException - - if the transaction could not be started

startTransaction

public void startTransaction(SessionScope session,
                             int transactionIsolation)
                      throws java.sql.SQLException
Start a transaction on the session with the specified isolation level.

Parameters:
session - - the session
Throws:
java.sql.SQLException - - if the transaction could not be started

commitTransaction

public void commitTransaction(SessionScope session)
                       throws java.sql.SQLException
Commit the transaction on a session

Parameters:
session - - the session
Throws:
java.sql.SQLException - - if the transaction could not be committed

endTransaction

public void endTransaction(SessionScope session)
                    throws java.sql.SQLException
End the transaction on a session

Parameters:
session - - the session
Throws:
java.sql.SQLException - - if the transaction could not be ended

startBatch

public void startBatch(SessionScope session)
Start a batch for a session

Parameters:
session - - the session

executeBatch

public int executeBatch(SessionScope session)
                 throws java.sql.SQLException
Execute a batch for a session

Parameters:
session - - the session
Returns:
- the number of rows impacted by the batch
Throws:
java.sql.SQLException - - if the batch fails

executeBatchDetailed

public java.util.List executeBatchDetailed(SessionScope session)
                                    throws java.sql.SQLException,
                                           BatchException
Execute a batch for a session

Parameters:
session - - the session
Returns:
- a List of BatchResult objects (may be null if no batch has been initiated). There will be one BatchResult object in the list for each sub-batch executed
Throws:
java.sql.SQLException - if a database access error occurs, or the drive does not support batch statements
BatchException - if the driver throws BatchUpdateException

setUserProvidedTransaction

public void setUserProvidedTransaction(SessionScope session,
                                       java.sql.Connection userConnection)
Use a user-provided transaction for a session

Parameters:
session - - the session scope
userConnection - - the user supplied connection

getDataSource

public javax.sql.DataSource getDataSource()
Get the DataSource for the session

Returns:
- the DataSource

getSqlExecutor

public SqlExecutor getSqlExecutor()
Getter for the SqlExecutor

Returns:
the SqlExecutor

getTransaction

public Transaction getTransaction(SessionScope session)
Get a transaction for the session

Parameters:
session - - the session
Returns:
- the transaction

autoEndTransaction

protected void autoEndTransaction(SessionScope session,
                                  boolean autoStart)
                           throws java.sql.SQLException
Throws:
java.sql.SQLException

autoCommitTransaction

protected void autoCommitTransaction(SessionScope session,
                                     boolean autoStart)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

autoStartTransaction

protected Transaction autoStartTransaction(SessionScope session,
                                           boolean autoStart,
                                           Transaction trans)
                                    throws java.sql.SQLException
Throws:
java.sql.SQLException

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

popRequest

protected RequestScope popRequest(SessionScope session,
                                  MappedStatement mappedStatement)

pushRequest

protected void pushRequest(RequestScope request)

popSession

protected SessionScope popSession()

pushSession

protected void pushSession(SessionScope session)

getResultObjectFactory

public ResultObjectFactory getResultObjectFactory()

setResultObjectFactory

public void setResultObjectFactory(ResultObjectFactory resultObjectFactory)