简体   繁体   中英

In web application I am using hibernate. In that when do I Open and Close the Session factory

I am developing a web application using JSP and hibernate. So, for that when do i open and close the session factory in hibernate...?

whether i need to open every time, when ever any user is logging-in or how..?

Since you're working on a web application, each call from the client runs in its own Thread. This means that hibernate sessions don't carry over from one call to the next. You will need to open and close the hibernate session on each incoming call. Preferably you would do this is close to the actual database calls as possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM