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  
注释掉任何一段的话,执行正常,我实在不知道错在哪里了.

解决方案 »

  1.   

    终于找到问题了,本来是用的hibernate自带的连接池,换了这个就出现问题,好想连接只能使用一次,如果只一个查询的话,连着刷新会一次正确一次错误,一个页面两个查询就会出现上述错误.
      

  2.   

    我觉得问题是不是在这里:你有两个事务,但只建立了一个session,应该是一个session(会话)对应一个事务!