使用org.hibernate.Query查询堆栈溢出,但是使用org.hibernate.Criteria查询却正常

使用org.hibernate.Query查询堆栈溢出,但是使用org.hibernate.Criteria查询却正常
查询如下:
public List queryStudentByClass(String classNum) {
Criteria criteria = getSession().createCriteria(Student.class);
return criteria.list();
}
public List queryStudentByClass(String classNum) {
StringBuffer hql = new StringBuffer();
hql.append(" from ");
hql.append(Student.class.getName());
Query query = this.getSession().createQuery(hql.toString());
return query.list();
}
如果使用第一个方法查询可以查到结果
但是使用第二个方法查询就会
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Servlet execution threw an exception


root cause

java.lang.StackOverflowError
javax.servlet.ServletException.getRootCause(ServletException.java:96)
org.springframework.web.util.NestedServletException.getCause(NestedServletException.java:69)
javax.servlet.ServletException.getRootCause(ServletException.java:96)
org.springframework.web.util.NestedServletException.getCause(NestedServletException.java:69)

你可能感兴趣的:(java,eclipse,Hibernate,Web,servlet)