From ba9abd1dd06d9c25d47d1edb8350c308ad91ec9f Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 20 Jun 2012 12:23:32 +0200 Subject: [PATCH] DATAMONGO-455 - Documentation mentions BasicQuery. --- src/docbkx/reference/mongodb.xml | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/docbkx/reference/mongodb.xml b/src/docbkx/reference/mongodb.xml index 0e822369b..e0285d037 100644 --- a/src/docbkx/reference/mongodb.xml +++ b/src/docbkx/reference/mongodb.xml @@ -624,7 +624,7 @@ public class MongoConfiguration { } - +
@@ -686,7 +686,7 @@ public class MongoConfiguration { <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/> </bean> - +
@@ -1546,8 +1546,17 @@ assertThat(p.getAge(), is(1)); follow a fluent API style so that you can easily chain together multiple method criteria and queries while having easy to understand code. Static imports in Java are used to help remove the need to see the 'new' keyword - for creating Query and Criteria instances so as to improve - readability.
+ for creating Query and + Criteria instances so as to improve readability. If + you like to create Query instances from a plain + JSON String use BasicQuery. + + + Creating a Query instance from a plain JSON String + + BasicQuery query = new BasicQuery("{ age : { $lt : 50 }, accounts.balance : { $gt : 1000.00 }}"); +List<Person> result = mongoTemplate.find(query, Person.class); + GeoSpatial queries are also supported and are described more in the section GeoSpatial Queries. @@ -1572,10 +1581,10 @@ assertThat(p.getAge(), is(1)); import static org.springframework.data.mongodb.core.query.Criteria.where; import static org.springframework.data.mongodb.core.query.Query.query; - ... +… - List<Person> result = mongoTemplate.find(query(where("age").lt(50).and("accounts.balance").gt(1000.00d)), Person.class); - +List<Person> result = mongoTemplate.find(query(where("age").lt(50) + .and("accounts.balance").gt(1000.00d)), Person.class); All find methods take a Query object as a @@ -1769,7 +1778,7 @@ import static org.springframework.data.mongodb.core.query.Query.query; Criteria withinBox (Box box) Creates a geospatial criterion using a $within $box operation - + @@ -2722,4 +2731,4 @@ mongoTemplate.dropCollection("MyNewCollection"); } }); - \ No newline at end of file +