I am using Spring Boot + MongoDB. I need to query database based on some criteria where my methods looks like below:
@Override
public List<MyCollection> findBuyByCriteria(Request request) {
Query search = new Query();
search.addCriteria(Criteria.where("ItmId").in(request.getItmIds()));
return mongoTemplate.find(search, MyCollection.class);
}
Problem that I am facing is: At line
search.addCriteria(Criteria.where("ItmId").in(request.getItmIds()));
request.getItmIds has 1 million Ids due to which I am getting an exception
org.bson.BsonMaximumSizeExceededException: Document size of 46282052 is larger than maximum of 16793600
Can anyone help me with this one?
If you are using Spring Data JPA, you can do something like: findBySomeField(String someField)
If you have a more complex query, you can actually use JPQL and write a custom query.
@Query(value = "SELECT o.* from SomeObject o WHERE :someField IS NULL OR o.someField = :somefield)
public findBySomeField(@Param("someField") String someField);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.