Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elemMatch of Class Criteria fails to build special cirteria [DATAMONGO-1068] #1989

Closed
spring-projects-issues opened this issue Oct 8, 2014 · 1 comment

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Oct 8, 2014

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)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 21, 2014

Thomas Darimont commented

Fixed in master. Back ported to 1.6.x, 1.5.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants