数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
来源:互联网 发布:淘宝换货能用运费险吗 编辑:程序博客网 时间:2024/06/05 11:27
最近用hibernate作数据库多表查询,结果遇到问题:
org.hibernate.QueryException: could not resolve property: ‘xxxx’of 经过各个步骤检查,还是没找到方法。结果,上网搜,网上文章也是大多都是“搬运工”,卡了好久。
不过一个意外,看到了一个知道的意外提醒:第三条所述,最终的以解决。
在此,整理一下这个问题的导致可能原因:
一、排查HQL语句中的类字段,看是否是java类中的字段,不要是数据库中的字段;
二、排查各个字段是否与类中字段一致,绝大多数可能是由于字段不匹配导致的问题;
三、如果以上两部都检查没有问题,那么很可能就是JavaBean命名规范不严格符合所导致的hibernate不能够匹配字段的问题。(附:命名规范)
JavaBean类命名规范:(注意:要实现可序列化接口(java.io.Serializable接口))
规范参考:http://www.cnblogs.com/Ghost-Draw-Sign/articles/1801476.html
(1)JavaBean 类必须是一个公共类,并将其访问属性设置为 public ,如: public class user{......}
(2)JavaBean 类必须有一个空的构造函数:类中必须有一个不带参数的公用构造器
(3)一个javaBean类不应有公共实例变量,类变量都为private ,如: private int id;
(4)属性应该通过一组存取方法(getXxx 和 setXxx)来访问,一般是IDE(Eclipse、JBuilder) 为属性生成getter/setter 方法
一般JavaBean属性以小写字母开头,驼峰命名格式,相应的 getter/setter 方法是 get/set 接上首字母大写的属性名。例如:属性名为userName,其对应的getter/setter 方法是 getUserName/setUserName。
但是,还有一些特殊情况:
1、如果属性名的第二个字母大写,那么该属性名直接用作 getter/setter 方法中 get/set 的后部分,就是说大小写不变。例如属性名为uName,方法是getuName/setuName。
2、如果前两个字母是大写(一般的专有名词和缩略词都会大写),也是属性名直接用作 getter/setter 方法中 get/set 的后部分。例如属性名为URL,方法是getURL/setURL。
3、如果首字母大写,也是属性名直接用作 getter/setter 方法中 get/set 的后部分。例如属性名为Name,方法是getName/setName,这种是最糟糕的情况,会找不到属性出错,因为默认的属性名是name。
所以在JavaBean命名时应该注意符合以上命名规范。
- 数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
- 数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
- 数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
- 数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
- 异常解决—org.hibernate.QueryException: could not resolve property: “xxx”
- 异常org.hibernate.QueryException: could not resolve property的原因
- 异常org.hibernate.QueryException: could not resolve property相关
- 异常org.hibernate.QueryException: could not resolve property的原因
- 异常**org.hibernate.QueryException: could not resolve property
- org.hibernate.QueryException: could not resolve property
- org.hibernate.QueryException: could not resolve property:
- org.hibernate.QueryException: could not resolve property
- org.hibernate.QueryException: could not resolve property:
- org.hibernate.QueryException: could not resolve property
- Struts Problem Report:org.hibernate.QueryException: could not resolve property: ?? of: com.zyc.xxx
- org.hibernate.QueryException: could not resolve property 错误解析
- Caused by: org.hibernate.QueryException: could not resolve property
- org.hibernate.QueryException: could not resolve property 错误解析
- Dubbo初接触
- Solr 分析器 Analyzer
- PLSQL Developer工具手工快速将Excel中的数据添加到数据库中
- Delphi中的几种布尔类型详解
- 通过logcat 过滤 Log 的常用方法
- 数据库异常整理:org.hibernate.QueryException: could not resolve property: “xxx”
- Android Notification 版本适配方案
- 网上商城系统网站链接开发问题
- ImportError: No module named setuptools 解决方案
- 机房收费系统 之 登录BUG (二)
- eclipse远程连接hadoop集群配置(windows及linux下)
- ios UITextField和 UITextView输入完毕后隐藏键盘
- LSM树由来、设计思想以及应用到HBase的索引
- photoshop工具详解(一)