调用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);
}
[apis
是仅包含一个DBRef的列表:new DBRef(“ api”,new ObjectId(“ 5e3ad9faaafa595898b6a682”))]]
searchKeyword
等于“帐户”
pageable
是Page request [number: 0, size 37, sort: UNSORTED]
。如果size
为36,则不会抛出StackOverflowError!{
$or: [{
'apis': {
$in: [{
'$ref': 'api',
'$id': ObjectId('5e3ad9faaafa595898b6a682')
}]
}
}, {
$text: {
$search: 'account'
}
}]
}
有人知道发生了什么吗?
术语:
public class Term {
@Id
private String id;
@NotBlank
@TextIndexed
@JsonProperty
private String name;
@NotBlank
@TextIndexed
@JsonProperty
private String objectType;
@Transient
@JsonProperty
private String snakeCase;
@NotEmpty
@JsonProperty
private List<String> functionalCategories;
@NotNull
@JsonProperty
private TermTypeEnum termType;
@NotEmpty
@JsonProperty
private Map<String, String> description;
@Setter
@NotNull
@JsonProperty
private TermStateEnum state;
@NotBlank
@TextIndexed
@JsonProperty
private String example;
@DBRef
@NotNull
@Indexed
@JsonProperty
private List<Api> apis;
@DBRef
@NotNull
@JsonProperty
private User contributor;
@NotBlank
@TextIndexed
@JsonProperty
private String version;
@DBRef
@JsonProperty
private Map<String, Term> attributes;
}
尽管可能会存在循环引用,因为Term具有Map
进行一些调试,我看到了堆栈溢出,因为最后,spring-data只继续实例化此Term(没有实例化,因此我看不到循环引用):
Term(id=5e3ad9faaafa595898b6a7ea, name=debitCurrency, objectType=string, snakeCase=debit_currency, functionalCategories=null, termType=BODY, description={"english"=Debit Currency.}, state=PROPOSED, example=null, apis=[Api(id=5e3ad9faaafa595898b6a67f, name=Payments-1.0.1, description=null, responsible=null)], contributor=null, version=null, attributes=null)
反过来不引用其他术语。
这里是另一个术语,仅供比较:
Term(id=5e3ad9faaafa595898b6a6c8, name=displayCardNumber, objectType=string, snakeCase=display_card_number, functionalCategories=null, termType=BODY, description={"english"=Related card number to the account.}, state=PROPOSED, example=null, apis=[Api(id=5e3ad9faaafa595898b6a682, name=Accounts-1.0.2, description=null, responsible=null)], contributor=null, version=null, attributes=null)
我没什么区别,但是
debitCurrency
产生堆栈溢出而displayCardNumber
没有产生堆栈溢出。
[我在调用MongoDB存储库接口的方法时收到StackOverflowError:公共接口TermRepository扩展了MongoRepository