com.ibatis.sqlmap.engine.impl

Class SqlMapExecutorDelegate

public class SqlMapExecutorDelegate extends Object

The workhorse that really runs the SQL
Field Summary
protected SqlExecutorsqlExecutor
Constructor Summary
SqlMapExecutorDelegate()
Default constructor
Method Summary
voidaddCacheModel(CacheModel model)
Add a cache model
voidaddMappedStatement(MappedStatement ms)
Add a mapped statement
voidaddParameterMap(ParameterMap map)
Add a parameter map
voidaddResultMap(ResultMap map)
Add a result map
protected voidautoCommitTransaction(SessionScope sessionScope, boolean autoStart)
protected voidautoEndTransaction(SessionScope sessionScope, boolean autoStart)
protected TransactionautoStartTransaction(SessionScope sessionScope, boolean autoStart, Transaction trans)
protected SessionScopebeginSessionScope()
protected StatementScopebeginStatementScope(SessionScope sessionScope, MappedStatement mappedStatement)
voidcommitTransaction(SessionScope sessionScope)
Commit the transaction on a session
intdelete(SessionScope sessionScope, String id, Object param)
Execute a delete statement
protected voidendSessionScope(SessionScope sessionScope)
protected voidendStatementScope(StatementScope statementScope)
voidendTransaction(SessionScope sessionScope)
End the transaction on a session
booleanequals(Object obj)
intexecuteBatch(SessionScope sessionScope)
Execute a batch for a session
ListexecuteBatchDetailed(SessionScope sessionScope)
Execute a batch for a session
voidflushDataCache()
Flush all of the data caches
voidflushDataCache(String id)
Flush a single cache by ID
CacheModelgetCacheModel(String id)
Get a cache model by ID
IteratorgetCacheModelNames()
Get an iterator of the cache models
DataExchangeFactorygetDataExchangeFactory()
Getter for the DataExchangeFactory
DataSourcegetDataSource()
Get the DataSource for the session
MappedStatementgetMappedStatement(String id)
Get a mappedstatement by its ID
IteratorgetMappedStatementNames()
Get an iterator of the mapped statements
intgetMaxTransactions()
DO NOT DEPEND ON THIS.
ParameterMapgetParameterMap(String id)
Get a parameter map by ID
IteratorgetParameterMapNames()
Get an iterator of all of the parameter maps
ResultMapgetResultMap(String id)
Get a result map by ID
IteratorgetResultMapNames()
Get an iterator of the result maps
ResultObjectFactorygetResultObjectFactory()
SqlExecutorgetSqlExecutor()
Getter for the SqlExecutor
TransactiongetTransaction(SessionScope sessionScope)
Get a transaction for the session
TransactionManagergetTxManager()
Getter for the transaction manager
TypeHandlerFactorygetTypeHandlerFactory()
Getter for the TypeHandlerFactory
inthashCode()
Objectinsert(SessionScope sessionScope, String id, Object param)
Call an insert statement by ID
booleanisCacheModelsEnabled()
Getter for the status of caching
booleanisEnhancementEnabled()
Getter for the status of CGLib enhancements
booleanisForceMultipleResultSetSupport()
booleanisLazyLoadingEnabled()
Getter for the status of lazy loading
booleanisStatementCacheEnabled()
booleanisUseColumnLabel()
ListqueryForList(SessionScope sessionScope, String id, Object paramObject)
Execute a query for a list
ListqueryForList(SessionScope sessionScope, String id, Object paramObject, int skip, int max)
Execute a query for a list
MapqueryForMap(SessionScope sessionScope, String id, Object paramObject, String keyProp)
Execute a query for a map.
MapqueryForMap(SessionScope sessionScope, String id, Object paramObject, String keyProp, String valueProp)
Execute a query for a map.
ObjectqueryForObject(SessionScope sessionScope, String id, Object paramObject)
Execute a select for a single object
ObjectqueryForObject(SessionScope sessionScope, String id, Object paramObject, Object resultObject)
Execute a select for a single object
PaginatedListqueryForPaginatedList(SessionScope sessionScope, String id, Object paramObject, int pageSize)
Execute a query and return a paginated list
voidqueryWithRowHandler(SessionScope sessionScope, String id, Object paramObject, RowHandler rowHandler)
Execute a query with a row handler.
voidsetCacheModelsEnabled(boolean cacheModelsEnabled)
Turn on or off caching
voidsetEnhancementEnabled(boolean enhancementEnabled)
Turn on or off CGLib enhancements
voidsetForceMultipleResultSetSupport(boolean forceMultipleResultSetSupport)
voidsetLazyLoadingEnabled(boolean lazyLoadingEnabled)
Turn on or off lazy loading
voidsetResultObjectFactory(ResultObjectFactory resultObjectFactory)
voidsetStatementCacheEnabled(boolean statementCacheEnabled)
voidsetTxManager(TransactionManager txManager)
Setter for the transaction manager
voidsetUseColumnLabel(boolean useColumnLabel)
voidsetUserProvidedTransaction(SessionScope sessionScope, Connection userConnection)
Use a user-provided transaction for a session
voidstartBatch(SessionScope sessionScope)
Start a batch for a session
voidstartTransaction(SessionScope sessionScope)
Start a transaction on the session
voidstartTransaction(SessionScope sessionScope, int transactionIsolation)
Start a transaction on the session with the specified isolation level.
intupdate(SessionScope sessionScope, String id, Object param)
Execute an update statement

Field Detail

sqlExecutor

protected SqlExecutor sqlExecutor

Constructor Detail

SqlMapExecutorDelegate

public SqlMapExecutorDelegate()
Default constructor

Method Detail

addCacheModel

public void addCacheModel(CacheModel model)
Add a cache model

Parameters: model - the model to add

addMappedStatement

public void addMappedStatement(MappedStatement ms)
Add a mapped statement

Parameters: ms - the mapped statement to add

addParameterMap

public void addParameterMap(ParameterMap map)
Add a parameter map

Parameters: map - the map to add

addResultMap

public void addResultMap(ResultMap map)
Add a result map

Parameters: map - the result map to add

autoCommitTransaction

protected void autoCommitTransaction(SessionScope sessionScope, boolean autoStart)

autoEndTransaction

protected void autoEndTransaction(SessionScope sessionScope, boolean autoStart)

autoStartTransaction

protected Transaction autoStartTransaction(SessionScope sessionScope, boolean autoStart, Transaction trans)

beginSessionScope

protected SessionScope beginSessionScope()

beginStatementScope

protected StatementScope beginStatementScope(SessionScope sessionScope, MappedStatement mappedStatement)

commitTransaction

public void commitTransaction(SessionScope sessionScope)
Commit the transaction on a session

Parameters: sessionScope - the session

Throws: SQLException - if the transaction could not be committed

delete

public int delete(SessionScope sessionScope, String id, Object param)
Execute a delete statement

Parameters: sessionScope - the session scope id - the statement ID param - the parameter object

Returns: - the number of rows deleted

Throws: SQLException - if the delete fails

endSessionScope

protected void endSessionScope(SessionScope sessionScope)

endStatementScope

protected void endStatementScope(StatementScope statementScope)

endTransaction

public void endTransaction(SessionScope sessionScope)
End the transaction on a session

Parameters: sessionScope - the session

Throws: SQLException - if the transaction could not be ended

equals

public boolean equals(Object obj)

executeBatch

public int executeBatch(SessionScope sessionScope)
Execute a batch for a session

Parameters: sessionScope - the session

Returns: - the number of rows impacted by the batch

Throws: SQLException - if the batch fails

executeBatchDetailed

public List executeBatchDetailed(SessionScope sessionScope)
Execute a batch for a session

Parameters: sessionScope - 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: SQLException if a database access error occurs, or the drive does not support batch statements BatchException if the driver throws BatchUpdateException

flushDataCache

public void flushDataCache()
Flush all of the data caches

flushDataCache

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

Parameters: id - the ID

getCacheModel

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

Parameters: id - the ID

Returns: - the cache model

getCacheModelNames

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

Returns: - the cache models

getDataExchangeFactory

public DataExchangeFactory getDataExchangeFactory()
Getter for the DataExchangeFactory

Returns: - the DataExchangeFactory

getDataSource

public DataSource getDataSource()
Get the DataSource for the session

Returns: - the DataSource

getMappedStatement

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

Parameters: id - the statement ID

Returns: - the mapped statement

getMappedStatementNames

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

Returns: - the iterator

getMaxTransactions

public int getMaxTransactions()

Deprecated:

DO NOT DEPEND ON THIS. Here to avoid breaking spring integration.

getParameterMap

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

Parameters: id - the ID

Returns: - the parameter map

getParameterMapNames

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

Returns: - the parameter maps

getResultMap

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

Parameters: id - the ID

Returns: - the result map

getResultMapNames

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

Returns: - the result maps

getResultObjectFactory

public ResultObjectFactory getResultObjectFactory()

getSqlExecutor

public SqlExecutor getSqlExecutor()
Getter for the SqlExecutor

Returns: the SqlExecutor

getTransaction

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

Parameters: sessionScope - the session

Returns: - the transaction

getTxManager

public TransactionManager getTxManager()
Getter for the transaction manager

Returns: - the transaction manager

getTypeHandlerFactory

public TypeHandlerFactory getTypeHandlerFactory()
Getter for the TypeHandlerFactory

Returns: - the TypeHandlerFactory

hashCode

public int hashCode()

insert

public Object insert(SessionScope sessionScope, String id, Object param)
Call an insert statement by ID

Parameters: sessionScope - the session id - the statement ID param - the parameter object

Returns: - the generated key (or null)

Throws: SQLException - if the insert fails

isCacheModelsEnabled

public boolean isCacheModelsEnabled()
Getter for the status of caching

Returns: - the status

isEnhancementEnabled

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

Returns: - the status

isForceMultipleResultSetSupport

public boolean isForceMultipleResultSetSupport()

isLazyLoadingEnabled

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

Returns: - the status

isStatementCacheEnabled

public boolean isStatementCacheEnabled()

isUseColumnLabel

public boolean isUseColumnLabel()

queryForList

public List queryForList(SessionScope sessionScope, String id, Object paramObject)
Execute a query for a list

Parameters: sessionScope - the session scope id - the statement ID paramObject - the parameter object

Returns: - the data list

Throws: SQLException - if the query fails

queryForList

public List queryForList(SessionScope sessionScope, String id, Object paramObject, int skip, int max)
Execute a query for a list

Parameters: sessionScope - 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: SQLException - if the query fails

queryForMap

public Map queryForMap(SessionScope sessionScope, String id, Object paramObject, String keyProp)
Execute a query for a map. The map has the table key as the key, and the results as the map data

Parameters: sessionScope - 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: SQLException - if the query fails

queryForMap

public Map queryForMap(SessionScope sessionScope, String id, Object paramObject, String keyProp, String valueProp)
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: sessionScope - 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: SQLException - if the query fails

queryForObject

public Object queryForObject(SessionScope sessionScope, String id, Object paramObject)
Execute a select for a single object

Parameters: sessionScope - the session scope id - the statement ID paramObject - the parameter object

Returns: - the result of the query

Throws: SQLException - if the query fails

queryForObject

public Object queryForObject(SessionScope sessionScope, String id, Object paramObject, Object resultObject)
Execute a select for a single object

Parameters: sessionScope - 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: SQLException - if the query fails

queryForPaginatedList

public PaginatedList queryForPaginatedList(SessionScope sessionScope, String id, Object paramObject, int pageSize)

Deprecated: All paginated list features have been deprecated

Execute a query and return a paginated list

Parameters: sessionScope - the session scope id - the statement ID paramObject - the parameter object pageSize - the page size

Returns: - the data list

Throws: SQLException - if the query fails

queryWithRowHandler

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

Parameters: sessionScope - the session scope id - the statement ID paramObject - the parameter object rowHandler - the row handler

Throws: SQLException - if the query fails

setCacheModelsEnabled

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

Parameters: cacheModelsEnabled - the new state of caching

setEnhancementEnabled

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

Parameters: enhancementEnabled - the new state

setForceMultipleResultSetSupport

public void setForceMultipleResultSetSupport(boolean forceMultipleResultSetSupport)

setLazyLoadingEnabled

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

Parameters: lazyLoadingEnabled - the new state of caching

setResultObjectFactory

public void setResultObjectFactory(ResultObjectFactory resultObjectFactory)

setStatementCacheEnabled

public void setStatementCacheEnabled(boolean statementCacheEnabled)

setTxManager

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

Parameters: txManager - the transaction manager

setUseColumnLabel

public void setUseColumnLabel(boolean useColumnLabel)

setUserProvidedTransaction

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

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

startBatch

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

Parameters: sessionScope - the session

startTransaction

public void startTransaction(SessionScope sessionScope)
Start a transaction on the session

Parameters: sessionScope - the session

Throws: SQLException - if the transaction could not be started

startTransaction

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

Parameters: sessionScope - the session

Throws: SQLException - if the transaction could not be started

update

public int update(SessionScope sessionScope, String id, Object param)
Execute an update statement

Parameters: sessionScope - the session scope id - the statement ID param - the parameter object

Returns: - the number of rows updated

Throws: SQLException - if the update fails

Copyright © 2011. All Rights Reserved.