db.getCollection('parentCollection').find({"mapObject.someField" : {$exists: true}})
我希望将其转换为如下方法 .
@Query("{mapObject.someField :{$exists : true}}")
List<Parent> findByMapKey(String id);
这里我在运行应用程序时遇到空指针异常
@Query("{mapObject.someField :{$exists : true}}")
here someField needs to be dynamic not fixed so i want my id to be passed in place of someField
这里也存在同样的问题 How to get parent object based upon key from child map in MongoRepository JAVA SpringBoot
最佳答案
这是不可能用 MongoRepository 做到的。相反,使用 MongoTemplate .
关于java - Mongo Shell 查询 MongoRepository,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59837048/