About hibernate session and sessionfactory

Source: Internet
Author: User
The hibernateutil class helps you build a sessionfactory to manage sessions.
When you want to use the session, take it from this class.

--------------------------------------------------------

It seems that the session is not thread-safe.
Hibernateutil. java encapsulates sessionfactory, configuration, and session. When you want to use it, you can directly use hibernateutil. getsession (), directly hibernateutil when you want to use it. closesession (yoursession ).
Similar to the connection pool connectionpool.

--------------------------------------------------------

Session is the singleton mode, and all Singleton modes are NOT thread-safe (generally, the name is followed by a factory, which is called the factory mode)
Hibernate only uses the non-secure Singleton mode in sessionfactory. It manages important information such as configuration in a unified manner, and the session is created by sessionfactory. The session is completely secure because it is not based on the singleton mode.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.