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.