繁体   English   中英

无法使用 spring 引导在 mongo 查询中使用十进制数将 $ 嵌套在 $in 下

[英]Cannot nest $ under $in with decimal number in mongo query by using spring boot

我们有一个在 robo mongo 中正确执行的 mongo 查询,用于查找 bigdecimal 值的列表,但我无法为其创建 java 代码。

我尝试通过使用 java 代码在$in运算符中使用$numberDecimal numberDecimal,但它不起作用并给我这个错误:

无法使用 spring 引导在 mongo 查询中使用十进制数将 $ 嵌套在 $in 下

所以我能够生成这种类型的查询,但它给了我错误:

db.getCollection("").aggregate({[
    "$match": {
        "$and" : [{ "xxx" : 
            {$in: [ {  "$numberDecimal" : "1235.000" 
} ] }} ]} ]})

而这个正在工作:

db.getCollection("").aggregate({[
    "$match": {
        "$and" : [{ "xxx" : 
            {$in: [ {  NumberDecimal("1235.000" )
} ] }} ]} ]})

当我们通过 spring boot/java 代码创建查询时,我们不需要做任何事情

db.getCollection("").aggregate({[
    "$match": {
        "$and" : [{ "xxx" : 
            {$in: [ {  "$numberDecimal" : "1235.000" 
} ] }} ]} ]})

当它到达数据库时,就像查询工作一样。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM