org.hibernate.hql.ast.QuerySyntaxException解决

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反射机制来完成动态转换这一功能的

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

«    2024年11月    »
123
45678910
11121314151617
18192021222324
252627282930
搜索
标签列表
网站分类
最新留言
    文章归档
    友情链接

    Powered By Z-BlogPHP 1.7.3

    Copyright Your WebSite.Some Rights Reserved.闽ICP备11018667号-2