The difference between hibernate opensession and getcurrentsession
•
Java
The difference between opensession and getcurrentsession: (1) each time opensession obtains a new session object, while getcurrentsession obtains a session object bound to the current thread; (2) Opensession does not need to be configured, while getcurrentsession needs to be configured
(3) Opensession needs to be closed manually, while getcurrentsession is closed automatically
(4) Session is asynchronous. To ensure thread safety, you need to use getcurrentsession
After running the following code, you can compare their (1)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码