|
|||||||||
| Home >> All >> com >> ibatis >> sqlmap >> engine >> [ impl overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.ibatis.sqlmap.engine.impl
Class SqlMapClientImpl

java.lang.Objectcom.ibatis.sqlmap.engine.impl.SqlMapClientImpl
- All Implemented Interfaces:
- ExtendedSqlMapClient, com.ibatis.sqlmap.client.SqlMapClient, com.ibatis.sqlmap.client.SqlMapExecutor, com.ibatis.sqlmap.client.SqlMapTransactionManager
- public class SqlMapClientImpl
- extends java.lang.Object
- implements ExtendedSqlMapClient
- extends java.lang.Object
Implementation of ExtendedSqlMapClient
| Field Summary | |
SqlMapExecutorDelegate |
delegate
Delegate for SQL execution |
private java.lang.ThreadLocal |
localSqlMapSession
|
private static org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
SqlMapClientImpl(SqlMapExecutorDelegate delegate)
Constructor to supply a delegate |
|
| Method Summary | |
void |
commitTransaction()
Commits the currently started transaction. |
int |
delete(java.lang.String id,
java.lang.Object param)
Executes a mapped SQL DELETE statement. |
void |
endTransaction()
Ends a transaction and rolls back if necessary. |
int |
executeBatch()
Executes (flushes) all statements currently batched. |
void |
flushDataCache()
Flushes all data caches. |
void |
flushDataCache(java.lang.String cacheId)
Flushes the data cache that matches the cache model ID provided. |
java.sql.Connection |
getCurrentConnection()
Returns the current connection in use. |
javax.sql.DataSource |
getDataSource()
Returns the DataSource instance currently being used by the SqlMapSession. |
SqlMapExecutorDelegate |
getDelegate()
Get the SQL delegate |
private SqlMapSessionImpl |
getLocalSqlMapSession()
|
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement |
getMappedStatement(java.lang.String id)
Get a mapped statement by ID |
com.ibatis.sqlmap.client.SqlMapSession |
getSession()
Deprecated. Use openSession() |
com.ibatis.sqlmap.engine.execution.SqlExecutor |
getSqlExecutor()
Get the SQL executor |
java.sql.Connection |
getUserConnection()
Deprecated. |
java.lang.Object |
insert(java.lang.String id,
java.lang.Object param)
Executes a mapped SQL INSERT statement. |
boolean |
isEnhancementEnabled()
Get the status of CGLib enhancements |
boolean |
isLazyLoadingEnabled()
Get the status of lazy loading |
com.ibatis.sqlmap.client.SqlMapSession |
openSession()
Returns a single threaded SqlMapSession implementation for use by one user. |
com.ibatis.sqlmap.client.SqlMapSession |
openSession(java.sql.Connection conn)
Returns a single threaded SqlMapSession implementation for use by one user. |
java.util.List |
queryForList(java.lang.String id,
java.lang.Object paramObject)
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects. |
java.util.List |
queryForList(java.lang.String id,
java.lang.Object paramObject,
int skip,
int max)
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range. |
java.util.Map |
queryForMap(java.lang.String id,
java.lang.Object paramObject,
java.lang.String keyProp)
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects that will be keyed into a Map. |
java.util.Map |
queryForMap(java.lang.String id,
java.lang.Object paramObject,
java.lang.String keyProp,
java.lang.String valueProp)
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects from which one property will be keyed into a Map. |
java.lang.Object |
queryForObject(java.lang.String id,
java.lang.Object paramObject)
Executes a mapped SQL SELECT statement that returns data to populate a single object instance. |
java.lang.Object |
queryForObject(java.lang.String id,
java.lang.Object paramObject,
java.lang.Object resultObject)
Executes a mapped SQL SELECT statement that returns data to populate the supplied result object. |
com.ibatis.common.util.PaginatedList |
queryForPaginatedList(java.lang.String id,
java.lang.Object paramObject,
int pageSize)
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects a page at a time. |
void |
queryWithRowHandler(java.lang.String id,
java.lang.Object paramObject,
com.ibatis.sqlmap.client.event.RowHandler rowHandler)
Executes a mapped SQL SELECT statement that returns a number of result objects that will be handled one at a time by a RowHandler. |
void |
setUserConnection(java.sql.Connection connection)
Allows the developer to easily use an externally supplied connection when executing statements. |
void |
startBatch()
Starts a batch in which update statements will be cached before being sent to the database all at once. |
void |
startTransaction()
Demarcates the beginning of a transaction scope. |
void |
startTransaction(int transactionIsolation)
Demarcates the beginning of a transaction scope using the specified transaction isolation. |
int |
update(java.lang.String id,
java.lang.Object param)
Executes a mapped SQL UPDATE statement. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
log
private static final org.apache.commons.logging.Log log
delegate
public SqlMapExecutorDelegate delegate
- Delegate for SQL execution
localSqlMapSession
private java.lang.ThreadLocal localSqlMapSession
| Constructor Detail |
SqlMapClientImpl
public SqlMapClientImpl(SqlMapExecutorDelegate delegate)
- Constructor to supply a delegate
| Method Detail |
insert
public java.lang.Object insert(java.lang.String id, java.lang.Object param) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL INSERT statement.
Insert is a bit different from other update methods, as it
provides facilities for returning the primary key of the
newly inserted row (rather than the effected rows). This
functionality is of course optional.
The parameter object is generally used to supply the input
data for the INSERT values.
- Specified by:
insertin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
update
public int update(java.lang.String id, java.lang.Object param) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL UPDATE statement.
Update can also be used for any other update statement type,
such as inserts and deletes. Update returns the number of
rows effected.
The parameter object is generally used to supply the input
data for the UPDATE values as well as the WHERE clause parameter(s).
- Specified by:
updatein interfacecom.ibatis.sqlmap.client.SqlMapExecutor
delete
public int delete(java.lang.String id, java.lang.Object param) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL DELETE statement.
Delete returns the number of rows effected.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the DELETE statement.
- Specified by:
deletein interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForObject
public java.lang.Object queryForObject(java.lang.String id, java.lang.Object paramObject) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a single object instance.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForObjectin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForObject
public java.lang.Object queryForObject(java.lang.String id, java.lang.Object paramObject, java.lang.Object resultObject) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
the supplied result object.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForObjectin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForList
public java.util.List queryForList(java.lang.String id, java.lang.Object paramObject) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a number of result objects.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForListin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForList
public java.util.List queryForList(java.lang.String id, java.lang.Object paramObject, int skip, int max) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a number of result objects within a certain range.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForListin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForPaginatedList
public com.ibatis.common.util.PaginatedList queryForPaginatedList(java.lang.String id, java.lang.Object paramObject, int pageSize) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a number of result objects a page at a time.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForPaginatedListin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForMap
public java.util.Map queryForMap(java.lang.String id, java.lang.Object paramObject, java.lang.String keyProp) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a number of result objects that will be keyed into a Map.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForMapin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryForMap
public java.util.Map queryForMap(java.lang.String id, java.lang.Object paramObject, java.lang.String keyProp, java.lang.String valueProp) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns data to populate
a number of result objects from which one property will be keyed into a Map.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryForMapin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
queryWithRowHandler
public void queryWithRowHandler(java.lang.String id, java.lang.Object paramObject, com.ibatis.sqlmap.client.event.RowHandler rowHandler) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes a mapped SQL SELECT statement that returns a number of
result objects that will be handled one at a time by a
RowHandler.
This is generally a good approach to take when dealing with large sets
of records (i.e. hundreds, thousands...) that need to be processed without
eating up all of the system resources.
The parameter object is generally used to supply the input
data for the WHERE clause parameter(s) of the SELECT statement.
- Specified by:
queryWithRowHandlerin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
startTransaction
public void startTransaction()
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Demarcates the beginning of a transaction scope. Transactions must be properly
committed or rolled back to be effective. Use the following pattern when working
with transactions:
try { sqlMap.startTransaction(); // do work sqlMap.commitTransaction(); } finally { sqlMap.endTransaction(); }Always call endTransaction() once startTransaction() has been called.- Specified by:
startTransactionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
startTransaction
public void startTransaction(int transactionIsolation)
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Demarcates the beginning of a transaction scope using the specified transaction
isolation. Transactions must be properly committed or rolled back to be effective.
Use the following pattern when working with transactions:
try { sqlMap.startTransaction(Connection.TRANSACTION_REPEATABLE_READ); // do work sqlMap.commitTransaction(); } finally { sqlMap.endTransaction(); }Always call endTransaction() once startTransaction() has been called.- Specified by:
startTransactionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
commitTransaction
public void commitTransaction()
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Commits the currently started transaction.
- Specified by:
commitTransactionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
endTransaction
public void endTransaction()
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Ends a transaction and rolls back if necessary. If the transaction has
been started, but not committed, it will be rolled back upon calling
endTransaction().
- Specified by:
endTransactionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
startBatch
public void startBatch()
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Starts a batch in which update statements will be cached before being sent to
the database all at once. This can improve overall performance of updates update
when dealing with numerous updates (e.g. inserting 1:M related data).
- Specified by:
startBatchin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
executeBatch
public int executeBatch()
throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapExecutor - Executes (flushes) all statements currently batched.
- Specified by:
executeBatchin interfacecom.ibatis.sqlmap.client.SqlMapExecutor
setUserConnection
public void setUserConnection(java.sql.Connection connection) throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Allows the developer to easily use an externally supplied connection
when executing statements.
Important: Using a user supplied connection basically sidesteps the transaction manager,
so you are responsible for appropriately. Here's a (very) simple example (throws SQLException):
try { Connection connection = dataSource.getConnection(); sqlMap.setUserConnection(connection); // do work connection.commit(); } catch (SQLException e) { try { if (connection != null) commit.rollback(); } catch (SQLException ignored) { // generally ignored } throw e; // rethrow the exception } finally { try { if (connection != null) connection.close(); } catch (SQLException ignored) { // generally ignored } }- Specified by:
setUserConnectionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
getUserConnection
public java.sql.Connection getUserConnection() throws java.sql.SQLException
- Deprecated.
- TODO Deprecated
- Specified by:
getUserConnectionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
- TODO Deprecated
getCurrentConnection
public java.sql.Connection getCurrentConnection() throws java.sql.SQLException
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Returns the current connection in use. If no connection exists null will
be returned. There may be no connection if no transaction has been started,
and if no user provided connection has been set.
- Specified by:
getCurrentConnectionin interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
getDataSource
public javax.sql.DataSource getDataSource()
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapTransactionManager - Returns the DataSource instance currently being used by the SqlMapSession.
- Specified by:
getDataSourcein interfacecom.ibatis.sqlmap.client.SqlMapTransactionManager
getMappedStatement
public com.ibatis.sqlmap.engine.mapping.statement.MappedStatement getMappedStatement(java.lang.String id)
- Description copied from interface:
ExtendedSqlMapClient - Get a mapped statement by ID
- Specified by:
getMappedStatementin interfaceExtendedSqlMapClient
isLazyLoadingEnabled
public boolean isLazyLoadingEnabled()
- Description copied from interface:
ExtendedSqlMapClient - Get the status of lazy loading
- Specified by:
isLazyLoadingEnabledin interfaceExtendedSqlMapClient
isEnhancementEnabled
public boolean isEnhancementEnabled()
- Description copied from interface:
ExtendedSqlMapClient - Get the status of CGLib enhancements
- Specified by:
isEnhancementEnabledin interfaceExtendedSqlMapClient
getSqlExecutor
public com.ibatis.sqlmap.engine.execution.SqlExecutor getSqlExecutor()
- Description copied from interface:
ExtendedSqlMapClient - Get the SQL executor
- Specified by:
getSqlExecutorin interfaceExtendedSqlMapClient
getDelegate
public SqlMapExecutorDelegate getDelegate()
- Description copied from interface:
ExtendedSqlMapClient - Get the SQL delegate
- Specified by:
getDelegatein interfaceExtendedSqlMapClient
openSession
public com.ibatis.sqlmap.client.SqlMapSession openSession()
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapClient - Returns a single threaded SqlMapSession implementation for use by
one user. Remember though, that SqlMapClient itself is a thread safe SqlMapSession
implementation, so you can also just work directly with it. If you do get a session
explicitly using this method be sure to close it! You can close a session using
the sqlMapSession.close() method.
- Specified by:
openSessionin interfacecom.ibatis.sqlmap.client.SqlMapClient
openSession
public com.ibatis.sqlmap.client.SqlMapSession openSession(java.sql.Connection conn)
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapClient - Returns a single threaded SqlMapSession implementation for use by
one user. Remember though, that SqlMapClient itself is a thread safe SqlMapSession
implementation, so you can also just work directly with it. If you do get a session
explicitly using this method be sure to close it! You can close a session using
the SqlMapSession.close() method.
This particular implementation takes a user provided connection as a parameter. This
connection will be used for executing statements, and therefore overrides any
configured datasources. Using this approach allows the developer to easily use an externally
supplied connection for executing statements.
Important: Using a user supplied connection basically sidesteps the datasource
so you are responsible for appropriately handling your connection lifecycle (i.e. closing).
Here's a (very) simple example (throws SQLException):
try { Connection connection = dataSource.getConnection(); SqlMapSession session = sqlMap.openSession(connection); // do work connection.commit(); } catch (SQLException e) { try { if (connection != null) commit.rollback(); } catch (SQLException ignored) { // generally ignored } throw e; // rethrow the exception } finally { try { if (connection != null) connection.close(); } catch (SQLException ignored) { // generally ignored } }- Specified by:
openSessionin interfacecom.ibatis.sqlmap.client.SqlMapClient
getSession
public com.ibatis.sqlmap.client.SqlMapSession getSession()
- Deprecated. Use openSession()
- TODO : DEPRECATED
- Specified by:
getSessionin interfacecom.ibatis.sqlmap.client.SqlMapClient
- TODO : DEPRECATED
flushDataCache
public void flushDataCache()
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapClient - Flushes all data caches.
- Specified by:
flushDataCachein interfacecom.ibatis.sqlmap.client.SqlMapClient
flushDataCache
public void flushDataCache(java.lang.String cacheId)
- Description copied from interface:
com.ibatis.sqlmap.client.SqlMapClient - Flushes the data cache that matches the cache model ID provided.
- Specified by:
flushDataCachein interfacecom.ibatis.sqlmap.client.SqlMapClient
getLocalSqlMapSession
private SqlMapSessionImpl getLocalSqlMapSession()
|
|||||||||
| Home >> All >> com >> ibatis >> sqlmap >> engine >> [ impl overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl