could not resolve property: qid of: org.lxh.myzngt.vo.Answer
错误信息:
org.hibernate.QueryException: could not resolve property: qid of: org.lxh.myzngt.vo.Answer
[SELECT COUNT(q.qid) FROM org.lxh.myzngt.vo.Question AS q WHERE q.qid IN (SELECT a.qid FROM org.lxh.myzngt.vo.Answer AS a WHERE a.userid=?)]
解决方法:初看之下以为是Action出错,读取不出总记录数allRecorders。后来又以为是sql语句错误,但是检查过了是没有错的。
最后发现是错在映射文件Answer.hbm.xml中;
原映射文件如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
<class name="org.lxh.myzngt.vo.Answer" table="answer">
<id name="aid" type="java.lang.Integer">
<column name="aid" />
<generator class="native" />
</id>
<many-to-one name="question" class="org.lxh.myzngt.vo.Question"
fetch="select">
<column name="qid" />
</many-to-one>
<property name="quesans" type="java.lang.String">
<column name="quesans" length="50" />
</property>
<property name="userid" type="java.lang.String">
<column name="userid" length="50" />
</property>
<property name="grade" type="java.lang.String">
<column name="grade" length="50" />
</property>
<property name="anstime" type="java.util.Date">
<column name="anstime" length="19" />
</property>
<property name="status" type="java.lang.Integer">
<column name="status" />
</property>
</class>
</hibernate-mapping>
后来只需要再加多一个属性
<property name="qid" type="java.lang.Integer">
<column name="qid" />
</property>
即可解决。
中间会出现如下错误:
org.hibernate.MappingException: Repeated column in mapping for entity: org.lxh.myzngt.vo.Answer column: qid (should be mapped with insert="false" update="false")
只需根据错误提示在fetch="select" 前面加上insert="false" update="false"就一切OK啦。
纠结了好久的。。。。
could not resolve property: qid of: org.lxh.myzngt.vo.Answer相关推荐
- org.hibernate.QueryException: could not resolve property
2019独角兽企业重金招聘Python工程师标准>>> org.hibernate.QueryException: could not resolve property错误的解决方法 ...
- 配置了yml文件但是提示cannot resolve property XXX
很多时候我们从网上找了一些配置yml的资源,但会提示cannot resolve property XXX,导致无法加载相应的资源从而运行错误. org.yaml.snakeyaml.scanner. ...
- org.hibernate.QueryException: could not resolve property:artical_uid
今天在使用hibernate查询数据库的时候,报了这个异常.出错的语句是在 detachedCriteria.add(Restrictions.eq("artical_uid",u ...
- could not resolve property(无法解析属性)
could not resolve property(无法解析属性) 顾名思义在写hql语句的时候,属性写错了! 请检查大小写,是实体类的,不是数据库表的! 一个一个检查,仔细看!
- 使用MyBatis框架遇到There is no getter for property named 'param' in 'class com.vo.ParamVO'
有时候在写完代码之后,运行程序会碰到一些让人觉得奇怪的问题,也是需要对框架去多多了解,下面遇到的也是一个经常会遇到问题. 严重: Servlet.service() for servlet [spri ...
- Could not set property ‘‘ of ‘class com.xxx.domain.vo.SelectTopicDetailsVO‘ with value ‘xxx‘
很显然是Mapper.XML的属性名写错了,就是没找到哪里拼错了. 最后 将domain中的类此属性复制粘贴到property中来,就对了神奇的很. /** 公版说明 */@ApiModelPrope ...
- node.js中模块_在Node.js中需要模块:您需要知道的一切
node.js中模块 by Samer Buna 通过Samer Buna 在Node.js中需要模块:您需要知道的一切 (Requiring modules in Node.js: Everythi ...
- object references an unsaved transient instance - save the transient instance before flushing .
http://blog.csdn.net/zdwzzu2006/article/details/7552234 异常1:not-null property references a null or t ...
- hibernate3.2多表关联查询常见问题
1.org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user]错误 今天学习hibernate.用MyEcli ...
- Hibernate提高性能的几点建议
Hibernate提高性能的几点建议 1.尽量少用one-to-many的映射,如果用最好把lazy设置成true,这样在查询主表时其关联子表就不会被查询,从而节约数据库的资源. 2. 当lazy设置 ...
最新文章
- 1亿参数4万样本BERT仍听不懂人话,我们离通用NLP能还有多远?
- UICollectionView的无限滚动---妥协做法
- SAP概念之利润中心
- 计算机组成原理 控制冒险,电子科大-系统结构实验-解决控制冒险.docx
- 浅析WebRtc中视频数据的接收和渲染流程
- phplivechat安卓app下载_掌音教师端下载软件-掌音教师版app下载v1.5.1 安卓官方版...
- 基于matlab 的燃油喷雾图像处理方法,基于MATLAB的燃油喷雾图像处理方法.doc
- 口算练习题(洛谷P1957题题解,Java语言描述)
- 在线笔记存代码_李宏毅《机器学习》完整版笔记发布
- Eigen删除矩阵的某行或某列
- split,splice,slice,substr,substring使用方法总结
- [CERC2017]Intrinsic Interval(神仙+线段树)
- 获取APP包名和activity的几种方法
- error Code:410 Error Message:appid and openid not match 威富通技术支持,兴业银行微信支付接入支持
- 计算机用户名登录取消,win7系统取消登录界面显示用户名的还原办法
- matlab三维绘图
- Mac VScode 常用快捷键
- 如何设计一个API快速开发平台?
- Fortran矩阵运算
- Matlab绘制三维定限截面柱体;已知(隐)函数方程,绘制三维空间图形