Which version of the MongoDB plugin? This was a bug in the past, but was fixed see
which verifies the behavior is correct
The issue https://jira.grails.org/browse/GPMONGODB-294 was fixed in version 3.0.0 of the plugin
Pergunta
We're using mongodb in our grails 2.3.5 app without hibernate. When using projection in criteria with minimum two fields the result returned is a different as returned in hibernate criteria. For example:
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)
}
Considering two instances are returned matching above criteria:-
Result returned when using mongodb will be:
[[1, 2], ['XYZ', 'ABC']]
While returned result when using hibernate will be:
[[1, 'XYZ'], [2, 'ABC']]
I'm not sure if this is by implementation or this is a bug.
Thank You,
SA
Solução
Which version of the MongoDB plugin? This was a bug in the past, but was fixed see
which verifies the behavior is correct
The issue https://jira.grails.org/browse/GPMONGODB-294 was fixed in version 3.0.0 of the plugin