String hql="select count(q.qid) from Question As q where q.qid in(select a.qid from Answer As a where a.userid=?)";
在执行时,出现:org.hibernate.QueryException: could not resolve property: qid of: org.lxh.myzntgt.vo.Answer [select count(q.qid) from org.lxh.myzntgt.vo.Question As q where q.qid in(select a.qid from org.lxh.myzntgt.vo.Answer As a where a.userid=?)]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1094)
at org.hibernate.hql.ast.FromElementType.getPropertyType(FromElementType.java:273)
at org.hibernate.hql.ast.FromElement.getPropertyType(FromElement.java:349)
这语句在mysql 客户端中可以执行
但在myeclipse 中不行,发现我的qid 有问题.但我查了一下,没发现什么不对呀,
映射方面都行,因为有一语句运行没问题:from Question As q where q.qid IN(select a.qid From Answer As a where a.userid=?)";
但上面的求记录数就不行,不知什么原因.
在执行时,出现:org.hibernate.QueryException: could not resolve property: qid of: org.lxh.myzntgt.vo.Answer [select count(q.qid) from org.lxh.myzntgt.vo.Question As q where q.qid in(select a.qid from org.lxh.myzntgt.vo.Answer As a where a.userid=?)]
at org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:37)
at org.hibernate.persister.entity.BasicEntityPersister.toType(BasicEntityPersister.java:1094)
at org.hibernate.hql.ast.FromElementType.getPropertyType(FromElementType.java:273)
at org.hibernate.hql.ast.FromElement.getPropertyType(FromElement.java:349)
这语句在mysql 客户端中可以执行
但在myeclipse 中不行,发现我的qid 有问题.但我查了一下,没发现什么不对呀,
映射方面都行,因为有一语句运行没问题:from Question As q where q.qid IN(select a.qid From Answer As a where a.userid=?)";
但上面的求记录数就不行,不知什么原因.
解决方案 »
- 跪求神人来帮助。。 JDIC调用IE内核的一些问题。。。
- 在线等高手指点。。。用JSP做验证码刷新时没刷新
- ordinal parameter mismatch,这是什么错?
- 谁看过java server faces核心编程这本书,有点小问题
- JAVA学习QQ群4527614
- 企业软件开发定向委培生
- 一个小问题,请帮忙(急!!!!!!!!!!!!!)
- 怎么样实现地址薄从网页上导入啊!
- 一个response.sendRedirect莫名其妙的问题--详情请进?
- jsp/servlet不用三方jar包怎么实现上传
- 帮忙,RSA私钥解密乱码,分数要多少给多少
- java开发WAP时怎么得到用户按下左右软件的事件
楼主【doren】截止到2008-06-27 14:33:35的历史汇总数据(不包括此帖):
发帖数:8 发帖分:70
结贴数:0 结贴分:0
未结数:8 未结分:70
结贴率:0.00 % 结分率:0.00 %
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
qid 在 org.lxh.myzntgt.vo.Question 对应的 映射文件(Question.hbm.xml)里 没有映射关系
或 映射不对
或者 与数据库映射的 数据类型
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 42
Current database: mldn+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| aid | int(11) | NO | PRI | NULL | auto_increment |
| quesans | varchar(50) | YES | | NULL | |
| userid | varchar(50) | YES | | NULL | |
| grade | varchar(50) | YES | | NULL | |
| anstime | datetime | YES | | NULL | |
| status | int(11) | YES | | NULL | |
| qid | int(11) | YES | MUL | NULL | |
+---------+-------------+------+-----+---------+----------------+
7 rows in set (0.41 sec)mysql> describe question;
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| qid | int(11) | NO | PRI | NULL | auto_increment |
| title | varchar(50) | YES | | NULL | |
| content | text | YES | | NULL | |
| itemid | int(11) | YES | | NULL | |
| subid | int(11) | YES | | NULL | |
| userid | varchar(50) | YES | | NULL | |
| grade | varchar(50) | YES | | NULL | |
| offerscore | int(11) | YES | | NULL | |
| status | int(11) | YES | | NULL | |
| questiontime | datetime | YES | | NULL | |
| clickcount | int(11) | YES | | NULL | |
| acceptflag | int(11) | YES | | NULL | |
| commenflag | int(11) | YES | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
13 rows in set (0.02 sec)
映射内容:
--answer.hbm.xml
<hibernate-mapping>
<class name="org.lxh.myzntgt.vo.Answer" table="answer">
<id name="aid" type="java.lang.Integer">
<column name="aid" />
<generator class="native"></generator>
</id>
<many-to-one name="question" class="org.lxh.myzntgt.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>
--Question.hbm.xml
<hibernate-mapping>
<class name="org.lxh.myzntgt.vo.Question" table="question">
<id name="qid" type="java.lang.Integer">
<column name="qid" />
<generator class="native"></generator>
</id>
<property name="title" type="java.lang.String">
<column name="title" length="50" />
</property>
<property name="content" type="java.lang.String">
<column name="content" length="65535" />
</property>
<property name="itemid" type="java.lang.Integer">
<column name="itemid" />
</property>
<property name="subid" type="java.lang.Integer">
<column name="subid" />
</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="offerscore" type="java.lang.Integer">
<column name="offerscore" />
</property>
<property name="status" type="java.lang.Integer">
<column name="status" />
</property>
<property name="questiontime" type="java.util.Date">
<column name="questiontime" length="19" />
</property>
<property name="clickcount" type="java.lang.Integer">
<column name="clickcount" />
</property>
<property name="acceptflag" type="java.lang.Integer">
<column name="acceptflag" />
</property>
<property name="commenflag" type="java.lang.Integer">
<column name="commenflag" />
</property>
<set name="answers" inverse="true" table="answer">
<key>
<column name="qid" ></column>
</key>
<one-to-many class="org.lxh.myzntgt.vo.Answer" />
</set>
</class>
</hibernate-mapping>
只有 与question 的一对多关系
没有与数据库的映射关系例如:
<property name="qid" type="java.lang.Integer">
<column name="qid"/>
</property>
只有 与question 的‘多对一’关系
只有 与question 的‘多对一’关系