hibernate  按条件查询_习惯累积沉淀_新浪博客

Date from = (Date)criteria.get("from");
Date to = (Date)criteria.get("to");
String sellProduct =(String)criteria.get("sellProduct");
String buyProduct =(String)criteria.get("buyProduct");
boolean delivery =((Boolean)criteria.get("delivery")).booleanValue();//boolean delivery =(boolean)criteria.get("delivery"); 错误.object不能转化为boolean
String orderBy = order.get(0);
String orderType  = order.get(1);
Filter filter = new Filter(LogicalType.AND);
filter.setEntityName(SpreadTradingRecord.class.getName());
if(orderType.equals("ASC")){
filter.addOrder(new Order(OrderType.ASC,orderBy));
}else{
filter.addOrder(new Order(OrderType.DESC,orderBy));
}
filter.addFilter(new Filter("time",ComparativeType.LESS,to));
filter.addFilter(new Filter("time",ComparativeType.GREATER,from));
//开市闭市的处理
Filter filter_or = new Filter(LogicalType.OR);
Filter filter_open = new Filter(LogicalType.AND);
Filter filter_close = new Filter(LogicalType.AND);
filter_open.addFilter(new Filter("sellProduct",ComparativeType.EQUAL,sellProduct));
filter_open.addFilter(new Filter("buyProduct", ComparativeType.EQUAL,buyProduct));
filter_open.addFilter(new Filter("type", ComparativeType.EQUAL,"OPEN"));
filter_close.addFilter(new Filter("sellProduct",ComparativeType.EQUAL,buyProduct));
filter_close.addFilter(new Filter("buyProduct", ComparativeType.EQUAL,sellProduct));
filter_close.addFilter(new Filter("type", ComparativeType.EQUAL,"CLOSE"));
filter_or.addFilter(filter_open);
filter_or.addFilter(filter_close);
filter.addFilter(filter_or);
// FIXME 没有delivery字段
//filter.addFilter(new Filter("delivery",  ComparativeType.EQUAL,delivery));
return dao.findByFilter(filter);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值