java吧 关注:1,237,655贴子:12,708,029
  • 3回复贴,共1

ssh项目下this.getHibernateTemplate().find(hql)空指针问题

只看楼主收藏回复

String hql = "select new cn.ahut.qige.bean.TDI1QueryResult(t.tid,t.title,u.username as author," +"t.time as posttime,t.replys) from Topic t,User u where t.authorid=u.id ";
String hql2 = "select new cn.ahut.qige.bean.TDI2QueryResult(topicid,u.username as lastreplyer,r1.time as lastreplytime) from Reply r1,Topic t,User u where r1.authorid=u.id and t.tid=r1.topicid " +" and r1.time>=all(select r2.time from Reply r2 where r1.topicid=r2.topicid)";
两个hql语句都在同一个action中通过调用this.getHibernateTemplate().find(hql)获取list
在mysql中执行都没有问题,放到java中作了相应的修改,第一个执行成功,第二个就报了空指针异常。是不是一个action中,不能使用this.getHibernateTemplate().find(hql)多次?还是其他原因?求大神帮忙啊


IP属地:广东1楼2014-05-10 19:38回复
    大神们来救救我吧,在线等啊


    IP属地:广东2楼2014-05-10 19:45
    回复
      在j8都得解决不了java问题,还能不能愉快的玩java了


      IP属地:广东3楼2014-05-10 20:06
      回复
        看来没有人帮我了,幸好本人智商足够高啊,弄了一阵终于知道问题所在了。如有人碰到相似问题可供参考一下。
        String hql2 = "select new cn.ahut.qige.bean.TDI2QueryResult(topicid,u.username as lastreplyer,r1.time as lastreplytime) from Reply r1,Topic t,User u where r1.authorid=u.id and t.tid=r1.topicid " +" and r1.time>=all(select r2.time from Reply r2 where r1.topicid=r2.topicid)";
        TDI2QueryResult(topicid,u.username a...这里topicid在mysql中运行是可以成功的,但是放到hibernate的hql中执行通不过。就是这样


        IP属地:广东4楼2014-05-10 21:31
        回复