再次求求大家了,hibernate问题

likestudyforwantgirl 2006-08-29 11:33:27
Session s = HibernateSessionFactory.currentSession();
String hql=null;
Iterator it=null;
//第一段
hql="From BmStbi where sbeno='02200607040001'";
it = s.createQuery(hql).list().iterator();
BmStbi bs = (BmStbi)it.next();
out.print(bs.getSbeno());
out.print(bs.getSbeno());

//第二段
hql="From BmDictionary where code='0313012'";
it = s.createQuery(hql).list().iterator();
BmDictionary bd=(BmDictionary)it.next();
out.print(bd.getCode());
out.print(bd.getName());

HibernateSessionFactory.closeSession();

问题:
两段同时执行就报异常:
org.apache.jasper.JasperException: could not execute query
注释掉任何一段的话,执行正常,我实在不知道错在哪里了.
...全文
204 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
guohaiwei 2006-08-30
  • 打赏
  • 举报
回复
不是sql,而是hql. 注意面向对象哦
dudu88656 2006-08-30
  • 打赏
  • 举报
回复
最基本的,看来LZ要细心了.
lbx19822004 2006-08-29
  • 打赏
  • 举报
回复
第二段的hql也改一下名字,不要和第一段的一样
lbx19822004 2006-08-29
  • 打赏
  • 举报
回复
呵呵,你把第二段的it改成Iterator itTwo = s.createQuery(hql).list().iterator();
后面也要改 itTwo.next(); 这样就可以了。
zhangj0571 2006-08-29
  • 打赏
  • 举报
回复
你的hql写错了,hql="From BmStbi bmStbi where bmStbi.sbeno='02200607040001'";

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧