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. 如果想讓spring幫你管理事務,只能在spring中配置SessionFactory。如果使用hibernate原有的sessionFactory,則只能自己手動管理事務。
如果想使用sessionFactory.getCurrentSession()方法,必須配置sessionFactory和jta或thread綁定。但是hibernate3.0不支持與thread綁定,3.1以上才支持。
3. sessionFactory.getCurrentSession()方法取得的session,在做數據庫操作時必須在事務中做,包
括只讀的查詢,否則會報錯。