我正在關注此Tutorial。我添加了另一個DAO,我正在檢索admin_roles表。該方法是這樣的休眠QuerySyntaxException,表未映射
public List findAllAdminRoleByUserName(String userName) {
List<AdminRoles> users = new ArrayList<AdminRoles>();
Query hqlQuery = sessionFactory.getCurrentSession().createQuery("from admin_roles AdminRoles where AdminRoles.username = ?");
users = hqlQuery.setString(0, userName).list();
if (users.size() > 0) {
return users;
} else {
return null;
}
}
當我試圖找回我得到以下錯誤
HTTP Status 500 - Request processing failed; nested exception is org.hibernate.hql.internal.ast.QuerySyntaxException: admin_roles is not mapped [from admin_roles AdminRoles where AdminRoles.username = ?]
我能夠在本教程中提到的管理表中獲取價值,我也創造了一些我能從中獲得價值的其他表格。但只有這張表沒有被映射。我也嘗試通過將表名從「admin_roles」更改爲adminroles(在數據庫和代碼中),我仍然得到相同的錯誤。
相關類看起來像這樣。此外,實體註釋是javax
@Entity
@Table(name = "admin_roles", uniqueConstraints = @UniqueConstraint(columnNames = { "role", "username" }))
public class AdminRoles{
我錯過了什麼嗎?在此先感謝