我正在嘗試使用generic-dao(http://code.google.com/p/hibernate-generic-dao/)。但是,在我的HibernateBaseDAO中,getSession()方法實現爲sessionFactory.getCurrentSession()。這導致對任何實體錯誤更新getCurrentSession()vs openSession()
org.hibernate.HibernateException: createCriteria is not valid without active transaction
然而,當我在地方的getCurrentSession()的使用的openSession(),它的工作原理。我沒有使用spring作爲pom.xml中的依賴項。我一直在閱讀openSession()和getCurrentSession(),但仍不明白爲什麼會發生這種情況?
您指定休眠使用ThreadLocalSessionContext的DAO的假設? –
是的,我已經指定了ThreadLocalSessionContext – obh