日期:2014-05-17  浏览次数:20707 次

hibernate query.list() 不执行
我写了一个类 执行到query.list();就不执行了为什么啊
代码如下
Java code


 public Iterator<Infos> getInfos(String infocataguid) {
        
        StringBuffer totalBuffer = new StringBuffer("select count(c.guid) ");
        StringBuffer iteratorBuffer = new StringBuffer("select * ");
        StringBuffer buffer = new StringBuffer(" from Infos c where infocataguid=?");        
        Session session = HibernateUtil.currentSession();
        Transaction transaction = session.beginTransaction();
        totalBuffer.append(buffer).append(" order by c.pubdate desc");
        Query query = session.createQuery(totalBuffer.toString());
        query.setString(0,infocataguid);
        Integer total = (Integer) query.uniqueResult();
        setTotal(total);
        Iterator<Infos> iterator = null;
        
        if (total > 0) {
            iteratorBuffer.append(buffer).append(" order by c.pubdate desc");            
            query = session.createQuery(iteratorBuffer.toString());
            //query.setString(0,infocataguid);
            
                           query= query.setFirstResult(startRow()).setMaxResults(num());
                           System.out.println(query);    
//能出结果 select * from infos t where t.infocataguid='402881c23527443c0135274541510002' order by t.pubstate    
            List<Infos> list = query.list();
            System.out.println("不继续执行");//不出结果
            iterator=list.iterator();
        
        }

        transaction.commit();
        HibernateUtil.closeSession();
        return iterator;
    }
        




为什么走到 query.list();就不走了


------解决方案--------------------
LZ,try catch()打印一下错误信息
------解决方案--------------------
Java code

System.out.println("不继续执行");//不出结果