当前位置: 代码迷 >> Java Web开发 >> hibernate query.list() 不执行解决方法
  详细解决方案

hibernate query.list() 不执行解决方法

热度:11681   发布时间:2013-02-25 21:20:50.0
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("不继续执行");//不出结果
  相关解决方案