Skip to content

Commit 35196e3

Browse files
committed
DATAMONGO-2509 - Polishing.
Fix typos, improve wording. Reworks documentation specific to MongoDB 3 and 4. Original pull request: #853.
1 parent 37d99c4 commit 35196e3

File tree

7 files changed

+53
-179
lines changed

7 files changed

+53
-179
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/package-info.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
/*
2-
* Copyright 2020 the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
171
/**
182
* MongoDB driver-specific utility classes for Json conversion.
193
*/

src/main/asciidoc/index.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ include::reference/mapping.adoc[leveloffset=+1]
3333
include::reference/sharding.adoc[leveloffset=+1]
3434
include::reference/kotlin.adoc[leveloffset=+1]
3535
include::reference/jmx.adoc[leveloffset=+1]
36-
include::reference/mongo-3.adoc[leveloffset=+1]
3736

3837
[[appendix]]
3938
= Appendix

src/main/asciidoc/reference/mapping.adoc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,16 +385,22 @@ public class Person {
385385
IMPORTANT: The `@Id` annotation tells the mapper which property you want to use for the MongoDB `_id` property, and the `@Indexed` annotation tells the mapping framework to call `createIndex(…)` on that property of your document, making searches faster.
386386
Automatic index creation is only done for types annotated with `@Document`.
387387

388-
WARNING: Auto index creation is turned **OFF** by default and need to be enabled via the configuration (see <<mapping.index-creation>>).
388+
WARNING: Auto index creation is **disabled** by default and needs to be enabled through the configuration (see <<mapping.index-creation>>).
389389

390390
[[mapping.index-creation]]
391391
=== Index Creation
392392

393-
Spring Data MongoDB can automatically create indexes for entity types annotated with `@Document`. Index creation must be explicitly enabled since version 3.0 to prevent undesired effects with collection lifecyle and performance impact. Indexes are automatically created for the initial entity set on application startup and when accessing an entity type for the first time while the application runs.
393+
Spring Data MongoDB can automatically create indexes for entity types annotated with `@Document`.
394+
Index creation must be explicitly enabled since version 3.0 to prevent undesired effects with collection lifecyle and performance impact.
395+
Indexes are automatically created for the initial entity set on application startup and when accessing an entity type for the first time while the application runs.
394396

395397
We generally recommend explicit index creation for application-based control of indexes as Spring Data cannot automatically create indexes for collections that were recreated while the application was running.
396398

397-
`IndexResolver` provides an abstraction for programmatic index definition creation if you want to make use of `@Indexed` annotations such as `@GeoSpatialIndexed`, `@TextIndexed`, `@CompoundIndex`. You can use index definitions with `IndexOperations` to create indexes. A good point in time for index creation is on application startup, specifically after the application context was refreshed, triggered by observing `ContextRefreshedEvent`. This event guarantees that the context is fully initialized. Note that at this time other components, especially bean factories might have access to the MongoDB database.
399+
`IndexResolver` provides an abstraction for programmatic index definition creation if you want to make use of `@Indexed` annotations such as `@GeoSpatialIndexed`, `@TextIndexed`, `@CompoundIndex`.
400+
You can use index definitions with `IndexOperations` to create indexes.
401+
A good point in time for index creation is on application startup, specifically after the application context was refreshed, triggered by observing `ContextRefreshedEvent`.
402+
This event guarantees that the context is fully initialized.
403+
Note that at this time other components, especially bean factories might have access to the MongoDB database.
398404

399405
.Programmatic Index Creation for a single Domain Type
400406
====

src/main/asciidoc/reference/mongo-3.adoc

Lines changed: 0 additions & 127 deletions
This file was deleted.

src/main/asciidoc/reference/mongo-repositories.adoc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This chapter points out the specialties for repository support for MongoDB. This
99
[[mongo-repo-usage]]
1010
== Usage
1111

12-
To access domain entities stored in a MongoDB, you can use our sophisticated repository support that eases implementation quite significantly. To do so, create an interface for your repository, as the following example shows:
12+
To access domain entities stored in a MongoDB, you can use our sophisticated repository support that eases implementation quite significantly.To do so, create an interface for your repository, as the following example shows:
1313

1414
.Sample Person entity
1515
====
@@ -28,7 +28,7 @@ public class Person {
2828
----
2929
====
3030

31-
Note that the domain type shown in the preceding example has a property named `id` of type `String`. The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as ID types.
31+
Note that the domain type shown in the preceding example has a property named `id` of type `String`.The default serialization mechanism used in `MongoTemplate` (which backs the repository support) regards properties named `id` as the document ID. Currently, we support `String`, `ObjectId`, and `BigInteger` as ID types.
3232
Please see <<mongo-template.id-handling, ID mapping>> for more information about on how the `id` field is handled in the mapping layer.
3333

3434
Now that we have a domain object, we can define an interface that uses it, as follows:
@@ -49,7 +49,7 @@ public interface PersonRepository extends PagingAndSortingRepository<Person, Str
4949
Right now this interface serves only to provide type information, but we can add additional methods to it later.
5050

5151
To start using the repository, use the `@EnableMongoRepositories` annotation.
52-
That annotation carries the same attributes as the namespace element. If no base package is configured, the infrastructure scans the package of the annotated configuration class. The following example shows how to use Java configuration for a repository:
52+
That annotation carries the same attributes as the namespace element.If no base package is configured, the infrastructure scans the package of the annotated configuration class.The following example shows how to use Java configuration for a repository:
5353

5454
.Java configuration for repositories
5555
====
@@ -100,11 +100,11 @@ If you would rather go with XML based configuration add the following content:
100100
----
101101
====
102102

103-
This namespace element causes the base packages to be scanned for interfaces that extend `MongoRepository` and create Spring beans for each one found. By default, the repositories get a `MongoTemplate` Spring bean wired that is called `mongoTemplate`, so you only need to configure `mongo-template-ref` explicitly if you deviate from this convention.
103+
This namespace element causes the base packages to be scanned for interfaces that extend `MongoRepository` and create Spring beans for each one found.By default, the repositories get a `MongoTemplate` Spring bean wired that is called `mongoTemplate`, so you only need to configure `mongo-template-ref` explicitly if you deviate from this convention.
104104

105105

106106

107-
Because our domain repository extends `PagingAndSortingRepository`, it provides you with CRUD operations as well as methods for paginated and sorted access to the entities. Working with the repository instance is just a matter of dependency injecting it into a client. Consequently, accessing the second page of `Person` objects at a page size of 10 would resemble the following code:
107+
Because our domain repository extends `PagingAndSortingRepository`, it provides you with CRUD operations as well as methods for paginated and sorted access to the entities.Working with the repository instance is just a matter of dependency injecting it into a client.Consequently, accessing the second page of `Person` objects at a page size of 10 would resemble the following code:
108108

109109
.Paging access to Person entities
110110
====
@@ -120,13 +120,13 @@ public class PersonRepositoryTests {
120120
public void readsFirstPageCorrectly() {
121121
122122
Page<Person> persons = repository.findAll(PageRequest.of(0, 10));
123-
assertThat(persons.isFirstPage(), is(true));
123+
assertThat(persons.isFirstPage()).isTrue();
124124
}
125125
}
126126
----
127127
====
128128

129-
The preceding example creates an application context with Spring's unit test support, which performs annotation-based dependency injection into test cases. Inside the test method, we use the repository to query the datastore. We hand the repository a `PageRequest` instance that requests the first page of `Person` objects at a page size of 10.
129+
The preceding example creates an application context with Spring's unit test support, which performs annotation-based dependency injection into test cases.Inside the test method, we use the repository to query the datastore.We hand the repository a `PageRequest` instance that requests the first page of `Person` objects at a page size of 10.
130130

131131
[[mongodb.repositories.queries]]
132132
== Query Methods

0 commit comments

Comments
 (0)