欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

hibernate測試時遇到的幾個異常及解決方法匯總

 更新時間:2019年03月29日 15:24:11   作者:光仔December  
今天小編就為大家分享一篇關(guān)于hibernate測試時遇到的幾個異常及解決方法匯總,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

今天使用hibernate3.6.5自己配置jar lib,在測試時遇到了幾個異常如下:

1.java.lang.NoSuchFieldError: INSTANCE

  • 解決:刪除hibernate-annotations.jar。

2.java.lang.ClassCastException: org.hibernate.annotations.common.reflection.java.JavaReflectionManager cannot be cast to org.hibernate.annotations.common.reflection.MetadataProviderInjector

  • 解決:刪除hibernate-commons-annotations.jar。

3.org.hibernate.HibernateException: No CurrentSessionContext configured!

  • 解決:添加hibernate-jpa-2.0-api-1.0.0.Final.jar

4.org.hibernate.HibernateException: No TransactionManagerLookup specified

   at org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:81)
   at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:687)
   at com.cvv.service.UserManager.exists(UserManager.java:16)

5.沒有CurrentSessionContext的配置。

解決:在集成Hibernate的環(huán)境下(例如Jboss),要在hibernate.cfg.xml中session-factory段加入: 

Xml代碼 :  

<property name="current_session_context_class">jta</property>

在不集成Hibernate的環(huán)境下(例如使用JDBC的獨立應(yīng)用程序),在hibernate.cfg.xml中session-factory段加入:

Xml代碼 :

<property name="current_session_context_class">thread</property>

測試運行,ok!

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論