mongodb you can't add a second

问题信息:

 

Due to limitations of the com.mongodb.BasicDBObject, you can't add a second 'createTime' expression specified as 'createTime : { "$lt" : 1468339200000}'. Criteria already contains 'createTime : { "$gt" : 1468252800000}'.

 

------------------------之前代码----------------------------------------

 

if(endTime!=null){

    endTime = DateUtil.getEndOfDay(endTime);

}

if (startTime !=null) {

    criteria.and("createTime").gte(startTime);

}

if(endTime!=null){

    criteria.and("createTime").lte(endTime);

}

 

------------------------修改代码----------------------------------------

 

if(endTime!=null){

    endTime = DateUtil.getEndOfDay(endTime);

}

if (startTime !=null&&endTime==null) {

    criteria.and("createTime").gte(startTime);

}else if(startTime==null&&endTime!=null){

    criteria.and("createTime").lte(endTime);

}else if(startTime!=null&&endTime!=null){

    criteria.andOperator(

            Criteria.where("createTime").gte(startTime),

            Criteria.where("createTime").lte(endTime)

    );
}

 

posted @ 2018-03-20 19:39  枫树湾河桥  阅读(4823)  评论(0编辑  收藏  举报
Live2D