为何hql语句会出错呢
阅读
首先,hibernate的所有语句都是正常,配置正常.
public List<Object> getObjByProperty(String objName, String propertyName, String value){
String hql = "from "+objName+" where ."+propertyName+" = '"+value+"'";
return this.getHibernateTemplate().find(hql);
}
hql语句打出来是
from RequestBill where requestNo = 'abv'??
不是应该
from Request_Bill xxx where requestNo yyy ='abv' 么???
请问是怎么回事啊?谢谢!
------解决方案--------------------
不对,应该是这样
String hql = "select o from "+objName+" o where o."+propertyName+"='"+value+"'";
------解决方案--------------------
hql
这样写 select s from sample(这个是表明) s(这个是自定义的) where s.id = "321";
你那个明显不对哦,照着这个改改
------解决方案--------------------
" where ." 这里多了个小数点~
------解决方案--------------------
Hibernate中使用hql语句,
查询语句是查询数据库表对应的实体类
String hql="from User where u.name='"+参数+"'";
阅读
上一篇:怎样将list数组写下hashMap中 下一篇:返回列表