我只想从表中返回一列。这是我的 DAO:
@SuppressWarnings("unchecked")
public String getUri() {
return sessionFactory.getCurrentSession()
.createQuery("uri from Templates WHERE state=1").toString();
}
Uri 是一个列。领域:
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
控制台说:
Request processing failed; nested exception is java.lang.IllegalArgumentException: node to traverse cannot be null!
第二个版本:
@SuppressWarnings("unchecked")
public String getUri() {
return (String) sessionFactory.getCurrentSession()
.createQuery("select uri from TEMPLATES WHERE state=1")
.uniqueResult();
}
安慰:
Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: TEMPLATES is not mapped [select uri from TEMPLATES WHERE state=1]