2011-07-04 41 views
0

我得到這個異常和很多R & D我無法解決它。HibernateException:沒有休眠會話綁定到線程

基本上,當它使用的findAll位於hbnpojogen-persistence-1.4.4.jar

public abstract interface GenericDAO<T, PK extends Serializable> 

    public abstract List<T> findAll(); 

()方法這是試圖用此方法的代碼的錯誤出現。

HibernateFactory.getDataDao().findAll(); 

回答

1

您需要在執行findAll()之前打開一個事務。見例如Spring的HibernateTransactionManager@Transactional註釋。

+0

我添加了所有這些交易但徒勞無功。我的控制器正在調用HibernateFactory.getDataDao()。findAll();在applicationcontext.xml文件中沒有提到 作爲bean。可能是這個問題。如何解決它? –

+0

你將需要發佈一些代碼。 –

+0

我在這裏發佈的代碼http://stackoverflow.com/questions/6571074/hibernatesystemexception-no-hibernate-session-bound-to-thread/6571532#6571532 –

相關問題