spring - Spring Boot - MongoDb 通过手动创建的查询查找
问题描述
在我的应用程序中,我手动创建了一些查询,然后我想简单地找到与创建的查询匹配的所有实体。为此,现在我必须创建一个 CustomXYRepository 接口和实现来调用 MongoOperations 的 find 方法。(例如:this.mongoOperation.find(query, AppointmentDao.class);)同样,我的查询是由应用程序本身构造的,因此我不会使用“静态”@Query 注释,我也想避免自定义存储库实现只为一条线。有没有可能在 Repository 接口中编写这样的方法?
public interface CalendarRepository extends MongoRepository<AppointmentDao, String> {
...
/**
* Find appointments by the given query.
*
* @param query
* @return
*/
List<AppointmentDao> findByQuery(Query query);
...
}
非常感谢,祝您有美好的一天!
解决方案
推荐阅读
- angular - 无法让 Angular Google Map AGM 与 Angular 11 一起使用
- ruby-on-rails - attr_accessor 没有从 rails 模型更新值
- f# - 在 F# 中,如何更改记录中属性的属性(语法?)
- python-3.x - 使用自定义正则表达式验证linkedIn url
- android - android.content.ReceiverCallNotAllowedException:BroadcastReceiver组件不允许注册接收intent
- assembly - NASM 基本加法程序给出重定位被截断以适应:R_386_16 针对 `.bss' 错误
- python - 无法定位 Selenium 中真正存在的元素
- php - 1 分钟后无法发送推送通知
- kuzzle - 使用钩子或订阅在 Kuzzle 中发送推送通知的更好方法是什么?
- java - 如何在没有打印语句的情况下扫描多行