You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/preface.adoc
+4-4
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,9 @@ The jumping off ground for learning about MongoDB is http://www.mongodb.org/[www
30
30
[[requirements]]
31
31
== Requirements
32
32
33
-
Spring Data MongoDB 1.x binaries requires JDK level 6.0 and above, and http://spring.io/docs[Spring Framework] 3.2.x and above.
33
+
Spring Data MongoDB 1.x binaries requires JDK level 6.0 and above, and http://spring.io/docs[Spring Framework] 4.0.x and above.
34
34
35
-
In terms of document stores, http://www.mongodb.org/[MongoDB] at least 2.4, preferably version 2.6.
35
+
In terms of document stores, http://www.mongodb.org/[MongoDB] at least 2.6.
36
36
37
37
== Additional Help Resources
38
38
@@ -46,12 +46,12 @@ There are a few support options available:
46
46
[[get-started:help:community]]
47
47
==== Community Forum
48
48
49
-
Spring Data on Stackoverflow http://stackoverflow.com/questions/tagged/spring-data[Stackoverflow] is a tag for all Spring Data (not just Document) users to share information and help each other. Note that registration is needed *only* for posting.
49
+
Spring Data on Stackoverflow http://stackoverflow.com/questions/tagged/spring-data[Stackoverflow] is a tag for all Spring Data (not just Document) users to share information and help each other. Note that registration is needed *only* for posting.
50
50
51
51
[[get-started:help:professional]]
52
52
==== Professional Support
53
53
54
-
Professional, from-the-source support, with guaranteed response time, is available from http://gopivotal.com/[Pivotal Sofware, Inc.], the company behind Spring Data and Spring.
54
+
Professional, from-the-source support, with guaranteed response time, is available from http://pivotal.io/[Pivotal Sofware, Inc.], the company behind Spring Data and Spring.
Person findByShippingAddresses(Address address); <3>
142
+
143
+
Stream<Person> findAllBy(); <4>
142
144
}
143
145
----
146
+
<1> The method shows a query for all people with the given lastname. The query will be derived parsing the method name for constraints which can be concatenated with `And` and `Or`. Thus the method name will result in a query expression of `{"lastname" : lastname}`.
147
+
<2> Applies pagination to a query. Just equip your method signature with a `Pageable` parameter and let the method return a `Page` instance and we will automatically page the query accordingly.
148
+
<3> Shows that you can query based on properties which are not a primitive type.
149
+
<4> Uses a Java 8 `Stream` which reads and converts individual elements while iterating the stream.
144
150
====
145
151
146
-
The first method shows a query for all people with the given lastname. The query will be derived parsing the method name for constraints which can be concatenated with `And` and `Or`. Thus the method name will result in a query expression of`{"lastname" : lastname}`. The second example shows how pagination is applied to a query. Just equip your method signature with a `Pageable` parameter and let the method return a `Page` instance and we will automatically page the query accordingly. The third examples shows that you can query based on properties which are not a primitive type.
152
+
147
153
148
154
NOTE: Note that for version 1.0 we currently don't support referring to parameters that are mapped as `DBRef` in the domain class.
149
155
@@ -154,6 +160,10 @@ NOTE: Note that for version 1.0 we currently don't support referring to paramete
154
160
| Sample
155
161
| Logical result
156
162
163
+
| `After`
164
+
| `findByBirthdateAfter(Date date)`
165
+
| `{"birthdate" : {"$gt" : date}}`
166
+
157
167
| `GreaterThan`
158
168
| `findByAgeGreaterThan(int age)`
159
169
| `{"age" : {"$gt" : age}}`
@@ -162,6 +172,10 @@ NOTE: Note that for version 1.0 we currently don't support referring to paramete
162
172
| `findByAgeGreaterThanEqual(int age)`
163
173
| `{"age" : {"$gte" : age}}`
164
174
175
+
| `Before`
176
+
| `findByBirthdateBefore(Date date)`
177
+
| `{"birthdate" : {"$lt" : date}}`
178
+
165
179
| `LessThan`
166
180
| `findByAgeLessThan(int age)`
167
181
| `{"age" : {"$lt" : age}}`
@@ -190,10 +204,18 @@ NOTE: Note that for version 1.0 we currently don't support referring to paramete
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/mongodb.adoc
+103-9
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ For most tasks you will find yourself using `MongoTemplate` or the Repository su
21
21
[[mongodb-getting-started]]
22
22
== Getting Started
23
23
24
-
Spring MongoDB support requires MongoDB 1.4 or higher and Java SE 5 or higher. The latest production release (2.4.9 as of this writing) is recommended. An easy way to bootstrap setting up a working environment is to create a Spring based project in http://spring.io/tools/sts[STS].
24
+
Spring MongoDB support requires MongoDB 2.6 or higher and Java SE 6 or higher. An easy way to bootstrap setting up a working environment is to create a Spring based project in http://spring.io/tools/sts[STS].
25
25
26
26
First you need to set up a running Mongodb server. Refer to the http://docs.mongodb.org/manual/core/introduction/[Mongodb Quick Start guide] for an explanation on how to startup a MongoDB instance. Once installed starting MongoDB is typically a matter of executing the following command: `MONGO_HOME/bin/mongod`
27
27
@@ -38,7 +38,7 @@ Then add the following to pom.xml dependencies section.
38
38
<dependency>
39
39
<groupId>org.springframework.data</groupId>
40
40
<artifactId>spring-data-mongodb</artifactId>
41
-
<version>1.4.1.RELEASE</version>
41
+
<version>1.7.0.RELEASE</version>
42
42
</dependency>
43
43
44
44
</dependencies>
@@ -48,7 +48,7 @@ Also change the version of Spring in the pom.xml to be
You will also need to add the location of the Spring Milestone repository for maven to your pom.xml which is at the same level of your <dependencies/> element
@@ -162,7 +162,7 @@ Even in this simple example, there are few things to take notice of
162
162
[[mongo.examples-repo]]
163
163
== Examples Repository
164
164
165
-
There is an https://github.com/spring-projects/spring-data-document-examples[github repository with several examples] that you can download and play around with to get a feel for how the library works.
165
+
There is an https://github.com/spring-projects/spring-data-examples[github repository with several examples] that you can download and play around with to get a feel for how the library works.
166
166
167
167
[[mongodb-connectors]]
168
168
== Connecting to MongoDB with Spring
@@ -1156,6 +1156,96 @@ As you can see we use the `NearQuery` builder API to set up a query to return al
1156
1156
1157
1157
The geo near operations return a `GeoResults` wrapper object that encapsulates `GeoResult` instances. The wrapping `GeoResults` allows to access the average distance of all results. A single `GeoResult` object simply carries the entity found plus its distance from the origin.
1158
1158
1159
+
[[mongo.geo-json]]
1160
+
=== GeoJSON Support
1161
+
1162
+
MongoDB supports http://geojeson.org/[GeoJSON] and simple (legacy) coordinate pairs for geospatial data. Those formats can both be used for storing as well as querying data.
1163
+
1164
+
NOTE: Please refer to the http://docs.mongodb.org/manual/core/2dsphere/#geospatial-indexes-store-geojson/[MongoDB manual on GeoJSON support] to learn about requirements and restrictions.
1165
+
1166
+
==== GeoJSON types in domain classes
1167
+
1168
+
Usage of http://geojeson.org/[GeoJSON] types in domain classes is straight forward. The `org.springframework.data.mongodb.core.geo` package contains types like `GeoJsonPoint`, `GeoJsonPolygon` and others. Those are extensions to the existing `org.springframework.data.geo` types.
1169
+
1170
+
====
1171
+
[source,java]
1172
+
----
1173
+
public class Store {
1174
+
1175
+
String id;
1176
+
1177
+
/**
1178
+
* location is stored in GeoJSON format.
1179
+
* {
1180
+
* "type" : "Point",
1181
+
* "coordinates" : [ x, y ]
1182
+
* }
1183
+
*/
1184
+
GeoJsonPoint location;
1185
+
}
1186
+
----
1187
+
====
1188
+
1189
+
==== GeoJSON types in repository query methods
1190
+
1191
+
Using GeoJSON types as repository query parameters forces usage of the `$geometry` operator when creating the query.
1192
+
1193
+
====
1194
+
[source,java]
1195
+
----
1196
+
public interface StoreRepository extends CrudRepository<Store, String> {
0 commit comments