spring orm - what's the different between SqlMapClient and SqlMapSeesion in ibatis? -
when read ibatis-sqlmap-2.3.4,i find both implements sqlmapexecutor.
sqlmapclientimpl insert localsqlmapsession provide thread safe.
but in spring2.5.6, execute method of sqlmapclienttemplate use sqlmapclientimpl this:
sqlmapsession session = this.sqlmapclient.opensession(); ... return action.doinsqlmapclient(session);
the opensession method return new sqlmapsessionimpl each time.
my questions are:
why sqlmapclienttemplate use sqlmapseesion instead of sqlmapclient ?
why localsqlmapsession of sqlmapclient unused in sqlmapclienttemplate ? use this:
return action.doinsqlmapclient(this.sqlmapclient);
what's different between sqlmapclient , sqlmapseesion ?
for first question, spring-orm explain in comment:
// need use sqlmapsession, need pass spring-managed // connection (potentially transactional) in. shouldn't necessary if // run against transactionawaredatasourceproxy underneath, unfortunately // still need make ibatis batch execution work properly: if ibatis // doesn't recognize existing transaction, automatically executes // batch every single statement...
the answer difference between ibatis' sqlmapclient , sqlmapsession can found in interface sqlmapclient's comments:
/** * returns single threaded sqlmapsession implementation use * 1 user. remember though, sqlmapclient thread safe sqlmapsession * implementation, can work directly it. if session * explicitly using method <b>be sure close it!</b> can close session using * sqlmapsession.close() method. * <p/> * * @return sqlmapsession instance. */ public sqlmapsession opensession();
Comments
Post a Comment