Could not obtain transaction-synchronized Session for current thread原因及解決方案

問題 用sessionFactory.getCurrentSession()這樣獲取session,拋了這異常。 解決 必須要將使用了sessionFactory.getCurrentSession()獲取session的代碼所在的方法加入到事務管理器中;否則獲取不到session了。 sessionFactory.getCurrentSession()是要基於事務的,才能實現session生命周
相關文章
相關標籤/搜索