Unable to resolve path [user.username], unexpected token [user] 异常
来源:互联网 发布:淘宝钱货一方 编辑:程序博客网 时间:2024/05/17 13:09
hql语句错误
原语句select user from User where user.username = '" + username + "' ——>select user from Useruser where user.username = '" + username + "'
下面是别人的解析:
"from po.test where test.name = sdf"
sdf是个字符串值,应该加单引号。不然Hibernate会把它作为类的属性看待,而你的类中是没有sdf这个属性的
问题之二:
from后直接写类名,不必加包名
问题之三:
test是类名,不能直接使用test.name(不能通过类来访问,就好像你不能通过类名去访问实例变量一样),请不要问为什么,记住这是HQL的语法要求就行了。
那怎么办呢?通常会用别名的方式解决,比如
from test as t where t.name = 'sdf'(别名就好像是test类的一个对象,通过对象就可以访问实例变量啦,哈哈)
所以你也可以这样写:
from test as test where test.name = 'sdf'(注意现在test.name中的test是别名了)
当然,仅对一个类进行操作,也可以不借助于别名:
from test where name = 'sdf'
0 0
- Unable to resolve path [user.username], unexpected token [user] 异常
- Unable to resolve path [user.username], unexpected token [user] 异常
- unable to authenticate user
- could not resolve property: username of: meituan.bean.User [from meituan.bean.User as u where u.user
- org.hibernate.QueryException: Unable to resolve path
- 异常积累:org.hibernate.hql.ast.QuerySyntaxError: User is not mapped. [from User where username=?]
- [VSS] Unable to Open User Login File
- VSS Unable to Open User Login File
- Unable to Open User Login File
- Unable to copy the user's Xauthorization file
- Setup Was Unable to Create a DCOM User Account
- VSS2005 出现 Unable to Open User Login File 问题
- [分享]Setup Was Unable to Create a DCOM User Account
- Unable to find models.User with id xx
- 导入工程常见异常 Unable to resolve target 'android-xxx'
- Unable to resolve target 'Google Inc.:Google APIs:3'异常
- Hibernate 异常StrategySelectionException: Unable to resolve name EhCacheRegionFactory
- Unable to resolve target
- VI的设计思想及使用
- 【题解】[wikioi2520]上学路线
- ios开发---将TableViewCell选中样式改为无色
- 互联网思维下的传统企业转型思考
- 六十一 C与指针笔记001
- Unable to resolve path [user.username], unexpected token [user] 异常
- JSON解析
- openCV中测试算法时间复杂度
- 应用层的AIDL用法
- wordpress通过文章的附加字段查询文章(query_posts)
- window(win7)+linux(ubuntu)双系统的安装以及windows重装后的引导修复问题
- UVALive - 3644 X-Plosives
- 学习TQ2440之裸奔第一章-电子相框
- 雨,一首美丽的歌