1. 程式人生 > 實用技巧 >hibernate 程式執行時的錯誤,及解決辦法(不定期更新)

hibernate 程式執行時的錯誤,及解決辦法(不定期更新)

193822722.jpg

這個錯誤是因為:沒有配置hibernate.cfg.xml中的最後一項 <mapping resource="org/hibernate/first/model/Student.hbm.xml"/>





194021349.jpg

這個錯誤是因為:

在配置hibernate快取的時候出的錯,我就把我這個快取程式碼刪除掉了。程式碼如下

<prop key="hibernate.cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</prop>




194227285.jpg

這個錯誤超級低階:資料庫方言裡面應該是:MySQLDialect 千萬不要寫成其他的,比如,MYSQL什麼的。



開啟hibernate.cfg.xml檔案是遇到如下錯誤的時候:

233648385.jpg

解決方法就是:

專案名上右鍵--〉myeclipse-->add hibernate capabilites -->next-->hibernate config file --> existing --> end

其中,在hibernate config file的地方,應該選擇你專案裡面的 src/hibernate.cfg.xml檔案,然後next 然後,不要new 一個什麼SessionFactory類就直接finish就ok了。



234514223.jpg

出現這個問題的原因,可能是因為你的資料庫裡面沒有對應的表。



轉載於:https://blog.51cto.com/ywj852752270/1266267