0

我们在没有休眠的 grails 2.3.5 应用程序中使用 mongodb。在具有最少两个字段的条件中使用投影时,返回的结果与在休眠条件中返回的结果不同。例如:

List usersList = User.withCriteria {
    projections {
        id()                          // For mongodb
        //property("id")              // For hibernate
        property('name', 'fullName')
    }
    def now = new Date()
    between('joinDate', now-365, now)
    maxResults(2)
}

考虑到两个实例返回匹配上述条件: -

使用 mongodb 时返回的结果为:

[[1, 2], ['XYZ', 'ABC']]

虽然使用休眠时返回的结果将是:

[[1, 'XYZ'], [2, 'ABC']]

我不确定这是通过实施还是这是一个错误。

谢谢你,

南非

4

1 回答 1

1

哪个版本的 MongoDB 插件?这是过去的错误,但已修复见

https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm-mongodb/src/test/groovy/org/grails/datastore/gorm/mongo/ProjectionsSpec.groovy#L38

验证行为是否正确

问题https://jira.grails.org/browse/GPMONGODB-294已在插件的 3.0.0 版本中修复

于 2014-05-13T11:43:53.120 回答