首页 新闻 会员 周边 捐助

hibernate query.list == 0 解决办法

0
悬赏园豆:20 [待解决问题]

先贴代码

    public void hqlQuery(){
    Session session = (Session) HibernateSessionUtil.getSession();
    String hql = "from Order as o where o.status=:status and o.total_price=:price";
    System.out.println(hql);
    Query query = session.createQuery(hql);
   
       query.setString("status","火速处理");
       query.setDouble("price",30);
      
       List<Order> orders = query.list();
       System.out.println(orders.size());  //这里为0
       for(Order order : orders){
        System.out.println(order.getPhone());
       }
       session.close();
   }

--控制台打印

Hibernate:
    select
        order0_.id as id1_,
        order0_.user_id as user2_1_,
        order0_.status as status1_,
        order0_.order_time as order4_1_,
        order0_.order_desc as order5_1_,
        order0_.total_price as total6_1_,
        order0_.receive_name as receive7_1_,
        order0_.full_address as full8_1_,
        order0_.postal_code as postal9_1_,
        order0_.mobile as mobile1_,
        order0_.phone as phone1_
    from
        d_order order0_
    where
        order0_.status=?
        and order0_.total_price=?
0

--数据库查询

    select
        order0_.id as id1_,
        order0_.user_id as user2_1_,
        order0_.status as status1_,
        order0_.order_time as order4_1_,
        order0_.order_desc as order5_1_,
        order0_.total_price as total6_1_,
        order0_.receive_name as receive7_1_,
        order0_.full_address as full8_1_,
        order0_.postal_code as postal9_1_,
        order0_.mobile as mobile1_,
        order0_.phone as phone1_
    from
        d_order order0_
    where
        order0_.status= '火速处理'
        and order0_.total_price= 83.3

--数据库查询结果

红色标记的,没有查到数据,但控制台打印的sql语句到数据库可查询出来

 

 

 

网上找了很久,没有解决,特此发帖

王高啊的主页 王高啊 | 初学一级 | 园豆:189
提问于:2017-06-05 20:42
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册