Unable to resolve path [user.username], unexpected token [user] 异常
来源:互联网 发布:基金组合 知乎 编辑:程序博客网 时间:2024/06/05 12:47
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'
1 1
- 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
- 遥感影像数据下载网址
- shell下获取系统时间方法
- C++函数调用原理理解
- POJ 3468 A Simple Problem with Integers(线段树,裸)
- LPCTSTR:类型
- Unable to resolve path [user.username], unexpected token [user] 异常
- 安卓手机存储卡使用技巧。
- 将DTS音频CD映像转换为双声道CD映像的脚本
- C#--工作笔记(直方图整体UserControls)
- VS改大小写的快捷键
- SOA与ESB的关系
- java工具类 获取包下所有类
- Cocos2d-x教程 CocoStudio篇 (3) UICheckBox 复选框控件
- 数据库导出CSV格式,并压缩成ZIP的形式导出