标题: you can't add a second 'treePath' criteria. Query already contains [打印本页] 作者: look_w 时间: 2019-5-11 11:35 标题: you can't add a second 'treePath' criteria. Query already contains
org.springframework.data.mongodb.InvalidMongoDbApiUsageException: Due to limitations of the com.mongodb.BasicDBObject, you can't add a second 'treePath' expression specified as 'treePath : { "$size" : 2}'. Criteria already contains 'treePath : { "$in" : [ "50137df5f49f9b4a6481d639"]}'.
正确用法:
int parentId = 100;
int level = 5;
Criteria c = new Criteria().andOperator(Criteria.where("treePath").is(parentId),
Criteria.where("treePath").size(level));
System.out.println(c.getCriteriaObject());