String hql = "from com.dc.portal.common.entity.FpKc c where kfhm=? and kprid=? and kczt='1' and nsrsbh=? and fs>(select count(1) from FpKp k where k.fpdm=c.fpDm and k.fphm>= c.fpqh and k.fphm<= c.fpzh)";
Query query = session.createQuery(hql);
query.setInteger(0, kfhm);
query.setString(1, kprid);
query.setString(2, nsrsbh);
return query.list();
语句有什么错误呢!

解决方案 »

  1.   

    什么问题?
    SQL语句有问题?没有SELECT  FROM ?
      

  2.   

    这个是HQL 语句! 看下有什么问题。。
      

  3.   

    你可以将SQL语句中MYSQL中测试一下
      

  4.   

    org.springframework.orm.hibernate3.HibernateQueryException: unexpected token: 1 near line 1, column 113 [from com.dc.portal.common.entity.FpKc c where kfhm=? and kprid=? and kczt='1' and nsrsbh=? and fs>(select count(1) from com.dc.portal.common.entity.FpKp k where k.fpdm=c.fpDm and k.fphm>= c.fpqh and k.fphm<= c.fpzh)]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 1 near line 1, column 113 [from com.dc.portal.common.entity.FpKc c where kfhm=? and kprid=? and kczt='1' and nsrsbh=? and fs>(select count(1) from com.dc.portal.common.entity.FpKp k where k.fpdm=c.fpDm and k.fphm>= c.fpqh and k.fphm<= c.fpzh)]
      

  5.   

    1.有必要加  com.dc.portal.common.entity. 这个么?
    2.你去了别名,但是where kfhm=? and kprid=? and kczt='1'  这几个都没有用别名。