【发布时间】:2017-04-06 14:26:55
【问题描述】:
升级到 spring data mongodb 1.10.1 后,运行以下查询时出现错误:
@Query("{$and :["
+ "{ $or : [ { $where: '?0 == null' } , { 'field1' : ?0 } ] },"
+ "{ $or : [ { $where: '?1 == null' } , { 'field2' : ?1 } ] },"
+ "]}")
public Page<Entity> findAll(String param1, String param2)
检查错误我看到 where 子句中的参数没有被引用,结果我得到:
org.springframework.data.mongodb.UncategorizedMongoDbException: 查询 失败,错误代码 139 和错误消息“ReferenceError: test_param_value 未定义:
我在这里看到一些答案推荐这种处理可选参数的方式 ((spring-data-mongo - optional query parameters?)),但它不再有效,而且我似乎在发布更改日志中找不到任何内容。
【问题讨论】:
-
它不知道 ?0 或 ?1 是什么类型,它无法比较 undefined == null 因为它无法弄清楚什么是 undefined。希望这是有道理的。
标签: spring mongodb spring-data-mongodb