1. 程式人生 > >出現“org.hibernate.QueryException: could not resolve property”錯誤的解決

出現“org.hibernate.QueryException: could not resolve property”錯誤的解決

org.hibernate.QueryException: could not resolve property

的問題,這是由於HQL和SQL的語句使用不同造成的。hibernate使用hql語法,而sql語法與hql是不一樣的。使用hql時,欄位名要與hbm.xml檔案中的“name”的值保持一致:

<propery name="Count" column="count" />

如上,則就要用首字母大寫的“Count”,不是小寫的。

所以,儘量保持加入sql表的欄位,與對映成hbm.xml檔案中屬性的name值一致,就會很少發生錯誤。