Java论坛网»Java技术»再次求求大家了,hibernate问题
再次求求大家了,hibernate问题
问?:
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
注释掉任何一段的话,执行正常,我实在不知道错在哪里了.
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
注释掉任何一段的话,执行正常,我实在不知道错在哪里了.
答!: 1:
你的hql写错了,hql="From BmStbi bmStbi where bmStbi.sbeno='02200607040001'";
答!: 2:
呵呵,你把第二段的it改成Iterator itTwo = s.createQuery(hql).list().iterator();
后面也要改 itTwo.next(); 这样就可以了。
后面也要改 itTwo.next(); 这样就可以了。
答!: 3:
第二段的hql也改一下名字,不要和第一段的一样
答!: 4:
最基本的,看来LZ要细心了.
答!: 5:
不是sql,而是hql. 注意面向对象哦
相关JAVA教程:
问个SWT的问题,希望大家帮忙解决!
各位大大,如何判断客户离开了我的网站...比较棘手
GUI设计中的类型检查
bot.jar包在什么地方可以下载到
javamail:请问怎样获取页面提交的邮件内容的类型即contentType???20分
关于Resin和Tomcat中文乱码的一个非常奇怪的问题
请问如何用SWT做一个可以在硬盘上打开图片文件的程序!
哪位高手帮我解决在EJB里面如何进行字符集转换?
我是毕业的计算机本科生,在工作的选择上犹豫
新手提问:关于struts+freemarker的问题?
为什么编码变成西欧(ISO)了?
WebService的传参的问题??在线等 100分