com.ibatis.sqlmap.engine.impl
Class SqlMapClientImpl

java.lang.Object
  extended by com.ibatis.sqlmap.engine.impl.SqlMapClientImpl
所有已实现接口:
SqlMapClient, SqlMapExecutor, SqlMapTransactionManager, ExtendedSqlMapClient

public class SqlMapClientImpl
extends java.lang.Object
implements SqlMapClient, ExtendedSqlMapClient

Implementation of ExtendedSqlMapClient


字段摘要
 SqlMapExecutorDelegate delegate
          Delegate for SQL execution
protected  java.lang.ThreadLocal localSqlMapSession
           
 
构造器摘要
SqlMapClientImpl(SqlMapExecutorDelegate delegate)
          Constructor to supply a delegate
 
方法摘要
 void commitTransaction()
          Commits the currently started transaction.
 int delete(java.lang.String id)
          Executes a mapped SQL DELETE statement.
 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.
 java.util.List executeBatchDetailed()
          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()
           
protected  SqlMapSessionImpl getLocalSqlMapSession()
           
 MappedStatement getMappedStatement(java.lang.String id)
           
 ResultObjectFactory getResultObjectFactory()
           
 SqlMapSession getSession()
          Deprecated. Use openSession()
 SqlExecutor getSqlExecutor()
           
 java.sql.Connection getUserConnection()
          Deprecated.  
 java.lang.Object insert(java.lang.String id)
          Executes a mapped SQL INSERT statement.
 java.lang.Object insert(java.lang.String id, java.lang.Object param)
          Executes a mapped SQL INSERT statement.
 boolean isEnhancementEnabled()
           
 boolean isLazyLoadingEnabled()
           
 SqlMapSession openSession()
          Returns a single threaded SqlMapSession implementation for use by one user.
 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)
          Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.
 java.util.List queryForList(java.lang.String id, 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.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)
          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)
          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.
 PaginatedList queryForPaginatedList(java.lang.String id, int pageSize)
          Deprecated. All paginated list features have been deprecated
 PaginatedList queryForPaginatedList(java.lang.String id, java.lang.Object paramObject, int pageSize)
          Deprecated. All paginated list features have been deprecated
 void queryWithRowHandler(java.lang.String id, java.lang.Object paramObject, 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 queryWithRowHandler(java.lang.String id, 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)
          Executes a mapped SQL UPDATE statement.
 int update(java.lang.String id, java.lang.Object param)
          Executes a mapped SQL UPDATE statement.
 
类方法继承: java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

字段详细信息

delegate

public SqlMapExecutorDelegate delegate
Delegate for SQL execution


localSqlMapSession

protected java.lang.ThreadLocal localSqlMapSession
构造器详细信息

SqlMapClientImpl

public SqlMapClientImpl(SqlMapExecutorDelegate delegate)
Constructor to supply a delegate

参数:
delegate - - the delegate
方法详细信息

insert

public java.lang.Object insert(java.lang.String id,
                               java.lang.Object param)
                        throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
insert in interface SqlMapExecutor
规范说明:
insert in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
param - The parameter object (e.g. JavaBean, Map, XML etc.).
返回:
The primary key of the newly inserted row. This might be automatically generated by the RDBMS, or selected from a sequence table or other source.
抛出异常:
java.sql.SQLException - If an error occurs.

insert

public java.lang.Object insert(java.lang.String id)
                        throws java.sql.SQLException
Description copied from interface: 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.

This overload assumes no parameter is needed.

规范说明:
insert in interface SqlMapExecutor
规范说明:
insert in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
返回:
The primary key of the newly inserted row. This might be automatically generated by the RDBMS, or selected from a sequence table or other source.
抛出异常:
java.sql.SQLException - If an error occurs.

update

public int update(java.lang.String id,
                  java.lang.Object param)
           throws java.sql.SQLException
Description copied from interface: 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).

规范说明:
update in interface SqlMapExecutor
规范说明:
update in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
param - The parameter object (e.g. JavaBean, Map, XML etc.).
返回:
The number of rows effected.
抛出异常:
java.sql.SQLException - If an error occurs.

update

public int update(java.lang.String id)
           throws java.sql.SQLException
Description copied from interface: 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.

This overload assumes no parameter is needed.

规范说明:
update in interface SqlMapExecutor
规范说明:
update in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
返回:
The number of rows effected.
抛出异常:
java.sql.SQLException - If an error occurs.

delete

public int delete(java.lang.String id,
                  java.lang.Object param)
           throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
delete in interface SqlMapExecutor
规范说明:
delete in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
param - The parameter object (e.g. JavaBean, Map, XML etc.).
返回:
The number of rows effected.
抛出异常:
java.sql.SQLException - If an error occurs.

delete

public int delete(java.lang.String id)
           throws java.sql.SQLException
Description copied from interface: SqlMapExecutor
Executes a mapped SQL DELETE statement. Delete returns the number of rows effected.

This overload assumes no parameter is needed.

规范说明:
delete in interface SqlMapExecutor
规范说明:
delete in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
返回:
The number of rows effected.
抛出异常:
java.sql.SQLException - If an error occurs.

queryForObject

public java.lang.Object queryForObject(java.lang.String id,
                                       java.lang.Object paramObject)
                                throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
queryForObject in interface SqlMapExecutor
规范说明:
queryForObject in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
返回:
The single result object populated with the result set data, or null if no result was found
抛出异常:
java.sql.SQLException - If more than one result was found, or if any other error occurs.

queryForObject

public java.lang.Object queryForObject(java.lang.String id)
                                throws java.sql.SQLException
Description copied from interface: SqlMapExecutor
Executes a mapped SQL SELECT statement that returns data to populate a single object instance.

This overload assumes no parameter is needed.

规范说明:
queryForObject in interface SqlMapExecutor
规范说明:
queryForObject in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
返回:
The single result object populated with the result set data, or null if no result was found
抛出异常:
java.sql.SQLException - If more than one result was found, or if any other error occurs.

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: 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.

规范说明:
queryForObject in interface SqlMapExecutor
规范说明:
queryForObject in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
resultObject - The result object instance that should be populated with result data.
返回:
The single result object as supplied by the resultObject parameter, populated with the result set data, or null if no result was found
抛出异常:
java.sql.SQLException - If more than one result was found, or if any other error occurs.

queryForList

public java.util.List queryForList(java.lang.String id,
                                   java.lang.Object paramObject)
                            throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
queryForList in interface SqlMapExecutor
规范说明:
queryForList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
返回:
A List of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

queryForList

public java.util.List queryForList(java.lang.String id)
                            throws java.sql.SQLException
Description copied from interface: SqlMapExecutor
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects.

This overload assumes no parameter is needed.

规范说明:
queryForList in interface SqlMapExecutor
规范说明:
queryForList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
返回:
A List of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

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: 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.

规范说明:
queryForList in interface SqlMapExecutor
规范说明:
queryForList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
skip - The number of results to ignore.
max - The maximum number of results to return.
返回:
A List of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

queryForList

public java.util.List queryForList(java.lang.String id,
                                   int skip,
                                   int max)
                            throws java.sql.SQLException
Description copied from interface: SqlMapExecutor
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects within a certain range.

This overload assumes no parameter is needed.

规范说明:
queryForList in interface SqlMapExecutor
规范说明:
queryForList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
skip - The number of results to ignore.
max - The maximum number of results to return.
返回:
A List of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

queryForPaginatedList

public PaginatedList queryForPaginatedList(java.lang.String id,
                                           java.lang.Object paramObject,
                                           int pageSize)
                                    throws java.sql.SQLException
Deprecated. All paginated list features have been deprecated

Description copied from interface: 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.

规范说明:
queryForPaginatedList in interface SqlMapExecutor
规范说明:
queryForPaginatedList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
pageSize - The maximum number of result objects each page can hold.
返回:
A PaginatedList of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

queryForPaginatedList

public PaginatedList queryForPaginatedList(java.lang.String id,
                                           int pageSize)
                                    throws java.sql.SQLException
Deprecated. All paginated list features have been deprecated

Description copied from interface: SqlMapExecutor
Executes a mapped SQL SELECT statement that returns data to populate a number of result objects a page at a time.

This overload assumes no parameter is needed.

规范说明:
queryForPaginatedList in interface SqlMapExecutor
规范说明:
queryForPaginatedList in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
pageSize - The maximum number of result objects each page can hold.
返回:
A PaginatedList of result objects.
抛出异常:
java.sql.SQLException - If an error occurs.

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: 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.

规范说明:
queryForMap in interface SqlMapExecutor
规范说明:
queryForMap in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
keyProp - The property to be used as the key in the Map.
返回:
A Map keyed by keyProp with values being the result object instance.
抛出异常:
java.sql.SQLException - If an error occurs.

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: 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.

规范说明:
queryForMap in interface SqlMapExecutor
规范说明:
queryForMap in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
keyProp - The property to be used as the key in the Map.
valueProp - The property to be used as the value in the Map.
返回:
A Map keyed by keyProp with values of valueProp.
抛出异常:
java.sql.SQLException - If an error occurs.

queryWithRowHandler

public void queryWithRowHandler(java.lang.String id,
                                java.lang.Object paramObject,
                                RowHandler rowHandler)
                         throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
queryWithRowHandler in interface SqlMapExecutor
规范说明:
queryWithRowHandler in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
paramObject - The parameter object (e.g. JavaBean, Map, XML etc.).
rowHandler - A RowHandler instance
抛出异常:
java.sql.SQLException - If an error occurs.

queryWithRowHandler

public void queryWithRowHandler(java.lang.String id,
                                RowHandler rowHandler)
                         throws java.sql.SQLException
Description copied from interface: 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.

This overload assumes no parameter is needed.

规范说明:
queryWithRowHandler in interface SqlMapExecutor
规范说明:
queryWithRowHandler in interface ExtendedSqlMapClient
参数:
id - The name of the statement to execute.
rowHandler - A RowHandler instance
抛出异常:
java.sql.SQLException - If an error occurs.

startTransaction

public void startTransaction()
                      throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
startTransaction in interface SqlMapTransactionManager
规范说明:
startTransaction in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException - If an error occurs while starting the transaction, or the transaction could not be started.

startTransaction

public void startTransaction(int transactionIsolation)
                      throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
startTransaction in interface SqlMapTransactionManager
规范说明:
startTransaction in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException - If an error occurs while starting the transaction, or the transaction could not be started.

commitTransaction

public void commitTransaction()
                       throws java.sql.SQLException
Description copied from interface: SqlMapTransactionManager
Commits the currently started transaction.

规范说明:
commitTransaction in interface SqlMapTransactionManager
规范说明:
commitTransaction in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException - If an error occurs while committing the transaction, or the transaction could not be committed.

endTransaction

public void endTransaction()
                    throws java.sql.SQLException
Description copied from interface: 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().

规范说明:
endTransaction in interface SqlMapTransactionManager
规范说明:
endTransaction in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException - If an error occurs during rollback or the transaction could not be ended.

startBatch

public void startBatch()
                throws java.sql.SQLException
Description copied from interface: 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).

规范说明:
startBatch in interface SqlMapExecutor
规范说明:
startBatch in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException - If the batch could not be started.

executeBatch

public int executeBatch()
                 throws java.sql.SQLException
Description copied from interface: SqlMapExecutor
Executes (flushes) all statements currently batched.

规范说明:
executeBatch in interface SqlMapExecutor
规范说明:
executeBatch in interface ExtendedSqlMapClient
返回:
the number of rows updated in the batch
抛出异常:
java.sql.SQLException - If the batch could not be executed or if any of the statements fails.

executeBatchDetailed

public java.util.List executeBatchDetailed()
                                    throws java.sql.SQLException,
                                           BatchException
Description copied from interface: SqlMapExecutor
Executes (flushes) all statements currently batched.

规范说明:
executeBatchDetailed in interface SqlMapExecutor
规范说明:
executeBatchDetailed in interface ExtendedSqlMapClient
返回:
a List of BatchResult objects. There will be one element in the list for each sub-batch executed. A sub-batch is created by adding a statement to the batch that does not equal the prior statement.
抛出异常:
java.sql.SQLException - if a database access error occurs, or the drive does not support batch statements
BatchException - if the driver throws BatchUpdateException
另请参见:
BatchException

setUserConnection

public void setUserConnection(java.sql.Connection connection)
                       throws java.sql.SQLException
Description copied from interface: 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
   }
 }
 

规范说明:
setUserConnection in interface SqlMapTransactionManager
规范说明:
setUserConnection in interface ExtendedSqlMapClient
抛出异常:
java.sql.SQLException

getUserConnection

public java.sql.Connection getUserConnection()
                                      throws java.sql.SQLException
Deprecated. 

TODO Deprecated

规范说明:
getUserConnection in interface SqlMapTransactionManager
规范说明:
getUserConnection in interface ExtendedSqlMapClient
返回:
Current connection
抛出异常:
java.sql.SQLException

getCurrentConnection

public java.sql.Connection getCurrentConnection()
                                         throws java.sql.SQLException
Description copied from interface: 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.

规范说明:
getCurrentConnection in interface SqlMapTransactionManager
规范说明:
getCurrentConnection in interface ExtendedSqlMapClient
返回:
The current connection or null.
抛出异常:
java.sql.SQLException

getDataSource

public javax.sql.DataSource getDataSource()
Description copied from interface: SqlMapTransactionManager
Returns the DataSource instance currently being used by the SqlMapSession.

规范说明:
getDataSource in interface SqlMapTransactionManager
规范说明:
getDataSource in interface ExtendedSqlMapClient
返回:
The DataSource instance currently being used by the SqlMapSession.

getMappedStatement

public MappedStatement getMappedStatement(java.lang.String id)
规范说明:
getMappedStatement in interface ExtendedSqlMapClient

isLazyLoadingEnabled

public boolean isLazyLoadingEnabled()
规范说明:
isLazyLoadingEnabled in interface ExtendedSqlMapClient

isEnhancementEnabled

public boolean isEnhancementEnabled()
规范说明:
isEnhancementEnabled in interface ExtendedSqlMapClient

getSqlExecutor

public SqlExecutor getSqlExecutor()
规范说明:
getSqlExecutor in interface ExtendedSqlMapClient

getDelegate

public SqlMapExecutorDelegate getDelegate()
规范说明:
getDelegate in interface ExtendedSqlMapClient

openSession

public SqlMapSession openSession()
Description copied from interface: 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.

规范说明:
openSession in interface SqlMapClient
规范说明:
openSession in interface ExtendedSqlMapClient
返回:
An SqlMapSession instance.

openSession

public SqlMapSession openSession(java.sql.Connection conn)
Description copied from interface: 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
   }
 }
 

规范说明:
openSession in interface SqlMapClient
规范说明:
openSession in interface ExtendedSqlMapClient
参数:
conn - - the connection to use for the session
返回:
An SqlMapSession instance.

getSession

public SqlMapSession getSession()
Deprecated. Use openSession()

TODO : DEPRECATED

规范说明:
getSession in interface SqlMapClient
规范说明:
getSession in interface ExtendedSqlMapClient
返回:
A session (DEPRECATED)

flushDataCache

public void flushDataCache()
Description copied from interface: SqlMapClient
Flushes all data caches.

规范说明:
flushDataCache in interface SqlMapClient
规范说明:
flushDataCache in interface ExtendedSqlMapClient

flushDataCache

public void flushDataCache(java.lang.String cacheId)
Description copied from interface: SqlMapClient
Flushes the data cache that matches the cache model ID provided. cacheId should include the namespace, even when useStatementNamespaces="false".

规范说明:
flushDataCache in interface SqlMapClient
规范说明:
flushDataCache in interface ExtendedSqlMapClient
参数:
cacheId - The cache model to flush

getLocalSqlMapSession

protected SqlMapSessionImpl getLocalSqlMapSession()

getResultObjectFactory

public ResultObjectFactory getResultObjectFactory()
规范说明:
getResultObjectFactory in interface ExtendedSqlMapClient