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
相關文章
- 解決SpringMVC+Hibernate錯誤: No Hibernate Session bound to threadSpringMVCSessionthread
- No Hibernate Session bound to thread, and configuration does not allow creationSessionthread
- 【hibernate】Session快取Session快取
- 如何管理hibernate 的session?Session
- Hibernate的session問題Session
- hibernate中的no session問題Session
- Java Hibernate 之 Session 狀態JavaSession
- HIBERNATE的SESSION和事務Session
- unity GPU bound or CPU boundUnityGPU
- hibernate的session.connection被session.dowork()替代Session
- hibernate.current_session_context_classSessionContext
- 請教hibernate 中session問題Session
- Hibernate中的Session快取問題Session快取
- C++ lower_bound upper_boundC++
- Scheduler&Task&Worker&Thread&Request&Session&Connection OF MSSQLthreadSessionSQL
- Hibernate取Session需要用單例嗎?Session單例
- Hibernate中Session.load/get區別Session
- Branch and Bound AlgorithmGo
- 菜鳥學SSH(九)——Hibernate——Session之save()方法Session
- Spring與Hibernate整合中的session問題SpringSession
- Hibernate中session.getconnection()的替代方法Session
- SpringMVC @Transactional的陷井大坑引發No Session found for current threadSpringMVCSessionthread
- Hibernate的Session的get()和load()方法區別Session
- hibernate的事務管理和session物件的詳解Session物件
- hibernate中Session的執行緒安全的討論Session執行緒
- hibernate open session in view 丟擲異常解決方法SessionView
- Straightforward Lower BoundAIForward
- 異常資訊解決:Could not obtain transaction-synchronized Session for current threadAIsynchronizedSessionthread
- Could not obtain transaction-synchronized Session for current thread原因及解決方案AIsynchronizedSessionthread
- 錯誤記錄(九)Could not obtain transaction-synchronized Session for current threadAIsynchronizedSessionthread
- 解決Hibernate session is closed的一種可行性方案Session
- Hibernate的一級快取Session和二級快取SessionFactory快取Session
- hibernate中建立session的兩種方式方式,區別在哪裡?Session
- BANG老師: 請教一下Hibernate的session問題Session
- js: get event handler bound to the elementJS
- CPU-bound(計算密集型) 和I/O bound(I/O密集型)
- 請問session bean怎麼和hibernate整和在一起啊??SessionBean
- function和bound method的區別Function