2012-03-07 13 views
0

ibatis-sqlmap-2.3.4を読むと、両方ともSqlMapExecutorを実装していることがわかります。ibatisのSqlMapClientとSqlMapSeesionの違いは何ですか?

SqlMapClientImplはスレッドセーフを提供するlocalSqlMapSessionで挿入します。新しいSqlMapSessionImpl毎回返す

SqlMapSession session = this.sqlMapClient.openSession(); 
    ... 
    return action.doInSqlMapClient(session); 

のOpenSession方法:

しかしspring2.5.6で、SqlMapClientTemplateのexecuteメソッドは次のようにSqlMapClientImplを使用しています。

私の質問は以下のとおりです。

代わりのSqlMapClientのはなぜSqlMapClientTemplate使用sqlMapSeesion?

なぜsqlMapClientのlocalSqlMapSessionがSqlMapClientTemplateで使用されていないのですか?

return action.doInSqlMapClient(this.sqlMapClient); 

SqlMapClientとSqlMapSeesionの違いは何ですか?あなたの最初の質問のための

答えて

3

、春-ORMはコメントで説明します。

// We always need to use a SqlMapSession, as we need to pass a Spring-managed 
// Connection (potentially transactional) in. This shouldn't be necessary if 
// we run against a TransactionAwareDataSourceProxy underneath, but unfortunately 
// we still need it to make iBATIS batch execution work properly: If iBATIS 
// doesn't recognize an existing transaction, it automatically executes the 
// batch for every single statement... 
のiBATIS'のSqlMapClientとSqlMapSessionの違いへの答えは、インタフェースの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 <b>be sure to close it!</b> You can close a session using 
* the sqlMapSession.close() method. 
* <p/> 
* 
* @return An SqlMapSession instance. 
*/ 
public SqlMapSession openSession();