No Hibernate Session bound to thread
用springside3生成的專案
在App啟動時,系統初始化載入的時候發生下面的錯誤
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:700)
把其中的getCurrentSession改成openSession就可以使用,當沒有事物啟動的時候getCurrentSession是無法建立Session的。
參考:http://www.iteye.com/topic/87035
opensession是從sessionfactory得到一個新的session,所以可以使用,而getCurrentSession是從當前執行緒 中得到事務開始時建立transaction的那個session,而你的事務沒有能正確的啟動,所以並沒有一個session繫結到當前執行緒,所以你也 得不到。
我的最終的解決辦法是通過註解給我的service加上事務即可:@Transactional
相關文章
- hibernate中的no session問題Session
- 如何區分 Connection、Thread和SessionthreadSession
- SpringMVC @Transactional的陷井大坑引發No Session found for current threadSpringMVCSessionthread
- C++ lower_bound upper_boundC++
- Could not obtain transaction-synchronized Session for current thread原因及解決方案AIsynchronizedSessionthread
- 異常資訊解決:Could not obtain transaction-synchronized Session for current threadAIsynchronizedSessionthread
- Straightforward Lower BoundAIForward
- Branch and Bound AlgorithmGo
- Hibernate一級快取(session)與二級快取(sessionFactory)的知識點。快取Session
- Hibernate SQL方言 (hibernate.dialect)SQL
- Hibernate
- Threadthread
- thread.Interrupt()與thread.Abort()thread
- hibernate使用
- Hibernate框架框架
- function和bound method的區別Function
- Hello,Threadthread
- Thread類thread
- Thread jointhread
- 手寫 Hibernate ORM 框架 00-hibernate 簡介ORM框架
- tomcat one connection one thread one request one threadTomcatthread
- hibernate詳解
- Spring 整合 HibernateSpring
- Hibernate配置OracleOracle
- Hibernate填坑
- Hibernate 查詢
- thread local in pythonthreadPython
- Thread.jointhread
- Thread知識thread
- Hibernate-ORM:13.Hibernate中的連線查詢ORM
- session和v$session說明Session
- laravel session 與 php session配置LaravelSessionPHP
- Analyzing and Reproducing the EOS Out-of-Bound Write Vulnerability in nodeos
- A Univariate Bound of Area Under ROC 論文小結
- Hibernate 註解方式
- Hibernate的基礎
- Hibernate框架簡介⑤框架
- Hibernate框架簡介④框架
- Hibernate框架簡介③框架