报错:HTTP Status 500 - org.hibernate.hql.ast.QuerySyntaxException: TB_FB_CHSF is not mapped [from TB_FB_CHSF t where t.chsfid= '-']
DAO实现的代码为
错误:查询的是类名(Chsfxx),也就是之前写好的model,不是表名TB_FB_CHSF
改为
又报错No positional parameters in query
hql的语句这么写貌似会出错,query中语句改为"from Chsfxx c where c.chsfid= ?"
成功。
DAO实现的代码为
public Chsfxx getChsfxxTable(final String daid) {
Query query = this
.getSession()
.createQuery(
"from TB_FB_CHSF t where t.chsfid= '"+ daid + "'");
query.setString(0, daid);
Iterator i = query.list().iterator();
Chsfxx card = null;
if (i.hasNext()) {
card = (Chsfxx) i.next();
}
return card;
}
错误:查询的是类名(Chsfxx),也就是之前写好的model,不是表名TB_FB_CHSF
改为
public Chsfxx getChsfxxTable(final String daid) {
Query query = this
.getSession()
.createQuery(
"from Chsfxx c where c.chsfid= '"+ daid + "'");
query.setString(0, daid);
Iterator i = query.list().iterator();
Chsfxx card = null;
if (i.hasNext()) {
card = (Chsfxx) i.next();
}
return card;
}
又报错No positional parameters in query
hql的语句这么写貌似会出错,query中语句改为"from Chsfxx c where c.chsfid= ?"
成功。