Home > Back-end >  Mybatis tools, the session will automatically shut down?
Mybatis tools, the session will automatically shut down?

Time:10-13


Write a mapper tools, add and remove check to do some general, directly in the cited sqlSession,
want to ask next, each call to the add and check after the change, the session will automatically shut down? ??



 @ Repository (value="https://bbs.csdn.net/topics/common") 
Public class CommonMapper {

@ the Resource (name="sqlSession")
Private SqlSession session;


/* *
* general query
* @ param sqlid
* @ param obj
* @ return
*/
The public & lt; E> List SelectForList (String statement, the Object parameter) {
Return this. The session. The selectList (statement, parameter);
}

/* *
* general update
* @ param statement sqlid

* @ param parameter parameters* @ return
*/
Public int updateForObj (String statement, the Object parameter) {
Return this. The session. The update (statement, parameter);
}

/* *
* general new
* @ param statement sqlid

* @ param parameter parameters* @ return
*/
Public int insertForObj (String statement, the Object parameter) {
Return this. The session. The insert (the statement, the parameter);
}

/* *
* general delete
* @ param statement sqlid

* @ param parameter parameters* @ return
*/
Public int deleteForObj (String statement, the Object parameter) {
Return this. The session. The delete (statement, parameter);
}
}

 



The classpath: mybatis - config. Xml


The classpath: com/test/spring/mapper/* mapper. Xml





CodePudding user response:

Need to have the code to display the shut down

CodePudding user response:

reference 1st floor tianfang response:
need a code to display the closing

But the manual shut, will be submitted to the SqlSession null pointer exception

CodePudding user response:

Want to ask is, if not manually shut down, will not lead to SQL connection number more and more,

CodePudding user response:

Will automatically shut down

reference u010717881 reply: 3/f
main want to ask is, if you do not manually close, will not lead to more and more people accessing SQL,


Will the

CodePudding user response:

This generic class is not good just can't use mybatis level cachenullnullnullnullnullnullnull
  • Related