zoukankan      html  css  js  c++  java
  • 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)
    
        );
    }
  • 相关阅读:
    ng-repeat高级用法
    使用 CSS3 实现超炫的 Loading(加载)动画效果
    ADO.NET访问数据库
    连接查询和分组查询
    T-SQL数据查询基础
    使用SQL语句操作数据
    使用表组织数据
    SQL Sever数据库
    使用属性升级Mybank
    C# 语法
  • 原文地址:https://www.cnblogs.com/fswhq/p/mongodb.html
Copyright © 2011-2022 走看看