Control the hibernate session(when to close it manually)

前端 未结 4 651
后悔当初
后悔当初 2020-12-04 06:43

I am new in hibernate,after read the hibernate api and tutorial,it seems that the session should closed when not used.

Like this:

Session sess=getSe         


        
4条回答
  •  半阙折子戏
    2020-12-04 06:57

    If you are getting session through sessionFactory.openSession() then you have to close it externally. Opened session for unintended period can cause the data leaks. Plus it can give invitation to Web App security threat.

提交回复
热议问题