I want to return only one column from table. This is my DAO:
@SuppressWarnings("unchecked")
public String getUri() {
return sessionFactory.getCurrentSession()
.createQuery("uri from Templates WHERE state=1").toString();
}
Uri is a column. Domain:
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
Console says:
Request processing failed; nested exception is java.lang.IllegalArgumentException: node to traverse cannot be null!
The second version:
@SuppressWarnings("unchecked")
public String getUri() {
return (String) sessionFactory.getCurrentSession()
.createQuery("select uri from TEMPLATES WHERE state=1")
.uniqueResult();
}
Console:
Request processing failed; nested exception is org.hibernate.hql.ast.QuerySyntaxException: TEMPLATES is not mapped [select uri from TEMPLATES WHERE state=1]