Closed
Description
Wizard Zhang opened DATAMONGO-1068 and commented
There is an entity like this:
public class Room {
private String name;
private List<Date> occupied;
}
I need to issue a criteria to fetch all documents in which none of elements of occupied falls into a specified date range. The query JSON is:
{
occupied : {
$not : {
$elemMatch : {
$gte : start,
$lte : end
}
}
}
}
Then, I tried on
Criteria c1 = new Criteria().gte(start).lte(end);
Criteria c = Criteria.where("occupied").not().elemMatch(c1);
But the serialization to JSON for c is:
{
occupied : {
$not : {
$elemMatch : {
}
}
}
}
It seems that c1 will be explained to empty Map by invoking elemMatch(Criteria) because I haven't assign a key to it. But really no key I can assign to it
Affects: 1.5.4 (Dijkstra SR4)
Referenced from: pull request #232
Backported to: 1.6.1 (Evans SR1), 1.5.5 (Dijkstra SR5)