我正在实现一个Spring Data Repository,并让我的存储库扩展了MongoRepository。我正在寻找一种在我的findBy方法上指定提示的方法,以便可以控制自己。我曾多次看到将非最佳指标选为获胜计划。
这是我的存储库现在的样子:
public interface AccountRepository extends MongoRepository<Account, ObjectId> {
@Meta(maxExcecutionTime = 60000L, comment = "Comment" )
public List<Account> findByUserIdAndBrandId(Long userId, Long brandId);
}
Run Code Online (Sandbox Code Playgroud)
我研究了一堆,发现spring数据中的JPARepository支持@QueryHint批注,但我不认为MongoDb支持该批注。我可以在findBy方法之上指定类似的注释来指定提示吗?
MongoTemplate允许指定提示,但是,我有大量的findBy方法,但我不想在其下方添加一个实现以指定提示。