你好,我想在spring mongo库中做现有查询。我读到过@ExistQuery,但我不知道如何在内部编写查询,我的方法现在:
@ExistsQuery("{ 'userAccount.socialTokenId': ?1}")
boolean existBySocialAccountId(String socialAccountId);
但是我得到了IndexOutOfBoundsException,'userAccount‘是一个包含变量socialTokenId的对象列表。我知道我可以获得整个用户对象并自己找到它,但我想优化我的查询:)。
发布于 2019-09-03 05:22:08
我相信你的问题是参数是零索引的,所以没有索引为1
的参数,这会导致IndexOutOfBoundsException
。
尝试将您的代码更改为以下代码:
@ExistsQuery("{ 'userAccount.socialTokenId': ?0}")
boolean existBySocialAccountId(String socialAccountId);
https://stackoverflow.com/questions/57762423
复制相似问题