I recommend the getCurrentSession
method because only with this method you have the possibility to be sure that the session will be closed from hibernate
Configuration J2EE Current Session.
If you use the openSession
method, you must close the sessions by yourself.
After i begin to work with hibernate i thought it does'n matter which method I use because all session will be closed automatically... i was wrong.
I had discovered with the SessionStatistics from hibernate
SessionStatistics
that the open session was already opened and never closed.
After i changed all calls to getCurrentSession
and impl
. the Session-per-request pattern opened session will be closed after work.