请教各位大神查询问题

yschat2012 2015-01-18 11:17:45
	int categoryid = Integer.parseInt(request.getParameter("id"));
String keyWord = request.getParameter("keyWord");
// 获取当前页
String currPage = request.getParameter("currPage");
String hql = "from Info d ";
Object[] where = null;
String action = request.getContextPath() + "/baseData/med.do?command=blurQuery";
// 转码
if (currPage != null && !currPage.isEmpty()) {
keyWord = StringUtil.encodeZh(keyWord);
}
if (keyWord != null && !keyWord.isEmpty()) {
action += "&keyWord=" + StringUtil.encodeURL(keyWord);
keyWord = "%" + keyWord + "%";

hql += " where d.categoryId like ? or d.title like ? or d.description like ?";
where = new Object[] {categoryid,keyWord, keyWord };
}
// 分页查询
Map map = this.getPage(hql, recPerPage, currPage, action, where);

错误提示:
could not resolve property: categoryId of: com.lyq.persistence.Info [select count(*) from com.lyq.persistence.Info d where d.categoryId like ? or d.title like ? or d.description like ?]
我查了下Info类,有categoryId啊
public class Info {

private int id; //id号
private String title;
private int categoryId;
不过它是与其他表关联的约束字段,配置代码如下:
<hibernate-mapping package="com.lyq.persistence">
<class name="Info" table="tb_info">
<!-- 主键 -->
<id name="id">
<generator class="native"/>
</id>

<property name="title" not-null="true" />
……
<!-- 与类别的多对一关系 -->
<many-to-one name="Category" column="categoryId" cascade="save-update"/>
</class>

是不是这个问题?该怎么解决?谢谢!!
...全文
156 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
yschat2012 2015-01-19
  • 打赏
  • 举报
回复
解决了,谢谢各位!!
夕阳下的高山 2015-01-19
  • 打赏
  • 举报
回复
基于你给的问题的描述,我想除了几种可能的原因: 1、可能需要在<many-to-one>中添加class属性,属性值为Category对应的类(包名+类名)
小生--幻 2015-01-18
  • 打赏
  • 举报
回复
基于你给的问题的描述,我想除了几种可能的原因: 1、可能需要在<many-to-one>中添加class属性,属性值为Category对应的类(包名+类名)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧