小编Edu*_*ard的帖子

调用页面大小大于 36 的 Spring Data MongoDB 存储库方法时出现 StackOverflowError

调用 MongoDB 存储库接口的方法时出现 StackOverflowError:

public interface TermRepository extends MongoRepository<Term, String>, QuerydslPredicateExecutor<Term> {
    // [...]
    @Query("{$or:[{'apis' : {$in : ?0 } }, {$text:{$search:?1}}]}")
    Page<Term> globalSearch(List<DBRef> apis, String searchKeyword, Pageable pageable);
}
Run Code Online (Sandbox Code Playgroud)
  • apis 是一个只有一个 DBRef 的列表: new DBRef("api", new ObjectId("5e3ad9faaafa595898b6a682"))

  • searchKeyword 等于“账户”

  • pageablePage request [number: 0, size 37, sort: UNSORTED]。如果size是 36,它不会抛出 StackOverflowError!
  • 查询被翻译成
{
    $or: [{
        'apis': {
            $in: [{
                '$ref': 'api',
                '$id': ObjectId('5e3ad9faaafa595898b6a682')
            }]
        }
    }, {
        $text: {
            $search: 'account'
        }
    }]
}
Run Code Online (Sandbox Code Playgroud)
  • 如果我直接在 mongo …

java stack-overflow spring spring-data-mongodb spring-boot

5
推荐指数
1
解决办法
257
查看次数