2012-03-07 2 views
0

ibatis-sqlmap-2.3.4를 읽을 때 둘 다 SqlMapExecutor를 구현합니다.ibatis에서 SqlMapClient와 SqlMapSeesion의 차이점은 무엇입니까?

SqlMapClientImpl은 스레드 안전을 제공하는 localSqlMapSession과 함께 삽입합니다.

그러나 spring2.5.6에서

는 SqlMapClientTemplate의 실행 방법은 다음과 같이 SqlMapClientImpl를 사용

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

OpenSession에 방법마다 새로운 SqlMapSessionImpl을 반환합니다.

내 질문은 : 대신하는 SqlMapClient의

왜 SqlMapClientTemplate를 사용 sqlMapSeesion?

SqlMapClientTemplate에서 sqlMapClient의 localSqlMapSession이 사용되지 않는 이유는 무엇입니까? 다음과 같이 사용하십시오 :

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();