当前位置:Gxlcms > 数据库问题 > springboot jpa mongodb 多条件分页查询

springboot jpa mongodb 多条件分页查询

时间:2021-07-01 10:21:17 帮助过:140人阅读

id =XX

        Criteria criteria = Criteria.where("callerId").is(recorded.getCallerId());

criteria.and(“status”).is(Recorded.SUCCESS);

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

            criteria.andOperator(

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

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

            );

        }

query.addCriteria(criteria);

 

        //mongoTemplate.count计算总数

        long total = mongoTemplate.count(query, Recorded.class);

        

        // mongoTemplate.find 查询结果集

        List<Recorded> items = mongoTemplate.find(query.with(pageable), Recorded.class);

 

        return new PageImpl(items, pageable, total);

 

    }

springboot jpa mongodb 多条件分页查询

标签:status   pos   count   tar   stat   list   operator   opera   create   

人气教程排行