使用Hibernate框架时,运行出现“ student is not mapped [from student ... ]”错误

使用Hibernate框架时,运行出现“ org.hibernate.hql.ast.QuerySyntaxException: student is not mapped [from student...]”错误。

hql语句:String hql = "from student where phoneNum = ? and password = ?";

错误原因:from后面应该写实体类(Student.java)的名字,而非数据库中实体类对应的表名(student)。

改正:String hql = "from Student where phoneNum = ? and password = ?";

你可能感兴趣的:(使用Hibernate框架时,运行出现“ student is not mapped [from student ... ]”错误)