我用hibernate写HQL语句,想把表中的一个varchar字段的值进行比较,这个值是有小数部分的,不如一个commentsShopid字段,存的数据时5.0,类型是varchar,我想查询出来当这个值大于4.0的时候就取出来。请问各位大侠怎么实现。
我使用"from BbsScomments b where b.commentsShopid="+id+" and cast(b.commentsPingjia as decimal(10,3))>="+4.0
但hibernate好像对cast这个函数不大支持或者说对decimal类型不大支持。
不知道各位有什么好的方法能够实现

解决方案 »

  1.   

    那就不用hql语句了,
    Query query = session.createSQLQuery("标准sql语句");
      

  2.   

    "from BbsScomments b where b.commentsShopid="+id+" and cast(b.commentsPingjia as decimal(10,3))>="+4.0 
    -->是不是引号问题
    "from BbsScomments b where b.commentsShopid="+id+" and cast(b.commentsPingjia as decimal(10,3))>=4.0 "
      

  3.   

    多谢2位的,应该不是引号的问题,createSQLQuery这个方法可以,我当时咋就没想到呢!!