| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1170 人关注过本帖
标题:[求助][讨论]由hql查询语句引发的异常?
取消只看楼主 加入收藏
huluhulu88
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-5-19
收藏
 问题点数:0 回复次数:3 
[求助][讨论]由hql查询语句引发的异常?
hql = "from KmsComments as c , "
+ "KmsAddresslist as a where c.kmsUser.userId=a.kmsUser.userId and c.findId='"
+ questionId
+ "' and a.isExpert=0 order by Convert(varchar,answerTime,111) desc ";

我研究了很时间,也没有发现它的错误。

编译器报的异常:

java.lang.ClassCastException: [Ljava.lang.Object;
at org.ks.hulu.disdaoimpl.DisDaoImpl.listuserreply(DisDaoImpl.java:186)
at com.yourcompany.struts.action.QueryQuestionAction.execute(QueryQuestionAction.java:64)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)


这是程序的相关代码:

/**
* 查询指定问题的全部回复(全员讨论)
*
*/
public List listuserreply(int questionId, int commentsType) {
List<KmsComments> userlist = new ArrayList<KmsComments>();
List list = null;
String hql = "";
try {
switch (commentsType) {
// 创建hql语句,条件:isExpert=0
case 0:
// 知识评论
hql = "";
break;
case 1:
// 全员回复
System.out.println("进入case:1");

hql = "from KmsComments as c , "
+ "KmsAddresslist as a where c.kmsUser.userId=a.kmsUser.userId and c.findId='"
+ questionId
+ "' and a.isExpert=0 order by Convert(varchar,answerTime,111) desc ";

break;
case 2:
// 课题回复
hql = "";
break;
case 3:
// 我的学习心得
hql = "";
break;
default:
break;
}
// 执行:查询
list = this.session.createQuery(hql).list();

System.out.println("enter list");

for (java.util.Iterator iter = list.iterator(); iter.hasNext();) {
KmsComments commbean = (KmsComments) iter.next();
// 增加实体对象
userlist.add(commbean);

//=======test==========
System.out.println(commbean.getAnswer());
//======================
}
} catch (Exception ex) {
ex.printStackTrace();
}
return userlist;
}

[此贴子已经被作者于2007-8-13 17:20:28编辑过]

搜索更多相关主题的帖子: hql 语句 DIV userId 
2007-08-13 17:15
huluhulu88
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-5-19
收藏
得分:0 
这个是hibernate里的hql语句,不需要加select
虽然这种写法还是没有找到错误,但问题是解决了,不过是换的另外一种方法。

2007-08-16 12:11
huluhulu88
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-5-19
收藏
得分:0 

真的是,太正确了,谢谢啦!可是我已经用了另外一种方法解决了


2007-08-17 14:28
huluhulu88
Rank: 1
等 级:新手上路
帖 子:118
专家分:0
注 册:2007-5-19
收藏
得分:0 
如果有人需要我会把它贴出来

2007-08-17 14:29
快速回复:[求助][讨论]由hql查询语句引发的异常?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017905 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved