日期:2014-05-20  浏览次数:20847 次

用 spring 提供的 HibernateDaoSupport 多表查询问题。
public List getMenuListByUsername(String username)
{
  try {
String queryString = "from tb_MENU as menu,tb_USER as user,tb_ROLE as role,tb_PURVIEW as purview where (user.ROLE_ID=role.ID and role.ID=purview.ROLE_ID and purview.MENU_ID=menu.ID) and user.name=?";

return getHibernateTemplate().find(queryString, username);
} catch (RuntimeException re) {
log.error("find by property name failed", re);
throw re;
}
}

但产生异常。
org.hibernate.hql.ast.QuerySyntaxException: tb_MENU is not mapped [from tb_MENU as menu,tb_USER as user,tb_ROLE as role,tb_PURVIEW as purview where (user.ROLE_ID=role.ID and role.ID=purview.ROLE_ID and purview.MENU_ID=menu.ID) and user.name=?]

在hibernate+spring结合项目中如何用多表查询????


------解决方案--------------------
引用楼主 jrg9522 的帖子:
tb_MENU is not mapped