整合ssh事務問題

org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
	org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
  1. 1. 如果想讓spring幫你管理事務,只能在spring中配置SessionFactory。如果使用hibernate原有的sessionFactory,則只能自己手動管理事務。  

  2. 如果想使用sessionFactory.getCurrentSession()方法,必須配置sessionFactory和jta或thread綁定。但是hibernate3.0不支持與thread綁定,3.1以上才支持。   

 3. sessionFactory.getCurrentSession()方法取得的session,在做數據庫操作時必須在事務中做,包

括只讀的查詢,否則會報錯。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章