1
回答
Hibernate查询的结果不符合where查询条件
百度AI开发者大赛带你边学边开发,赢100万奖金,加群:418589053   
@Override
public List<BbMallOrderCartDetail> queryEntitiesByCartId(Integer cartId) {
String status = "已添加";
Object[] objs = new Object[1];
objs[0] = cartId;
StringBuffer sql = new StringBuffer("select * from bb_mall_order_cart_detail detail where detail.cart_id=? and detail.status='已添加' order by detail.id");
List<BbMallOrderCartDetail> list = findBySQL(sql.toString(), BbMallOrderCartDetail.class, objs[0]);
if (list == null || list.size() == 0) {
return null;
}
return list;

}

得到查询结果:BbMallOrderCartDetail [id=1, price=86.36, qty=1, inventory=10, status=已删除, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=2, price=33.0, qty=1, inventory=10, status=已删除, createdAt=2016-10-22 12:12:35.0, updatedAt=2016-10-22 12:12:35.0]
BbMallOrderCartDetail [id=3, price=86.21, qty=1, inventory=10, status=已删除, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=4, price=86.21, qty=1, inventory=10, status=已添加, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=5, price=86.21, qty=1, inventory=10, status=已添加, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=6, price=86.21, qty=1, inventory=10, status=已添加, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=7, price=52.03, qty=1, inventory=10, status=已添加, createdAt=2016-09-22 07:55:22.0, updatedAt=2016-09-27 05:35:21.0]
BbMallOrderCartDetail [id=8, price=33.0, qty=1, inventory=10, status=已添加, createdAt=2016-10-22 19:30:31.0, updatedAt=2016-10-22 19:30:31.0]


举报
qinjamesko
发帖于2年前 1回/165阅
顶部