I am working on a web application. Typically, at the beginning of a query (via architecture code), a Hibernate session is opened to work with DB transactions. At the end of the request, the session is closed. This works great for all of our transactions, except that in one specific case I want to start a thread from a request. This thread will trigger database transactions.
From the thread, I call "sessionFactory.openSession ()", and with this session I am executing my transactions. The problem is that when the request ends, the thread itself may not necessarily be completed. Therefore, when the request completes and the thread tries to execute another database transaction, I get a Hibernate session that is closed! error.
In any case, from my stream, can I open a "clean" session, not related to the one that was opened at the beginning of the request?
source
share