Hi guys,
I am upgrading my application from hibernate 4.2.18 to 5.1.0. I am using current session from session factory for repeated execution in single thread. I was used to that when connection to database is lost, commit on transaction remove session from threadlocal. How to achieve similar behavior in 5.1.0. version? Because now I am obtaining same session in case of that connection to database is lost. 
Code:
        val session = sessionFactory.currentSession
        var transaction: Transaction? = null
        try {
            transaction = session.beginTransaction()
            // do something with session
            transaction!!.commit()
        } catch (e: Exception) {
            transaction?.rollback()
            throw e
        }