Hibernate中的HQL问题
org.hibernate.hql.ast.QuerySyntaxException: student is not mapped. [from student]
Caused by:
org.hibernate.hql.ast.QuerySyntaxException: student is not mapped. [from student]
原因student应为Student
HQL查询的是个类,首字母要大写,如from Student
如果是小写的student,Hibernate则不会找到相应的类来进行处理,可推断出HQL查询语句是区分大小写的,要求表名,字段名要与相匹配的类,属性同名,而且要严格保持一致,包括大小写,而SQL语句是不区分大小写的.
转换的语句为:
Hibernate: select student0_.id as id1_, student0_.name as name1_, student0_.sex as sex1_, student0_.tel as tel1_, student0_.age as age1_, student0_.email as email1_, student0_.pwd as pwd1_, student0_.userGroup as userGroup1_, student0_.education as education1_, student0_.CuserId as CuserId1_, student0_.UuserId as UuserId1_, student0_.CreateDateTime as CreateD12_1_, student0_.LastUpdateTime as LastUpd13_1_ from student student0_ where 1=1
可以分析出Hibernate是通过Java反射机制来完成动态转换这一功能的