Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= Index Creation

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.
Index creation must be explicitly enabled since version 3.0 to prevent undesired effects with collection lifecycle 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.

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.
Expand Down Expand Up @@ -166,7 +166,7 @@ public class DomainType {

Hashed indexes can be created next to other index definitions like shown below, in that case both indices are created:

.Example Hashed Index Usage togehter with simple index
.Example Hashed Index Usage together with simple index
====
[source,java]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ template.createCollection(Person.class, CollectionOptions.empty().schema(schema)
[[mongo.jsonSchema.generated]]
== Generating a Schema

Setting up a schema can be a time consuming task and we encourage everyone who decides to do so, to really take the time it takes.
Setting up a schema can be a time-consuming task, and we encourage everyone who decides to do so, to really take the time it takes.
It's important, schema changes can be hard.
However, there might be times when one does not want to balked with it, and that is where `JsonSchemaCreator` comes into play.

Expand All @@ -115,7 +115,7 @@ public class Person {
this.age = age;
}

// gettter / setter omitted
// getter / setter omitted
}

MongoJsonSchema schema = MongoJsonSchemaCreator.create(mongoOperations.getConverter())
Expand Down Expand Up @@ -146,7 +146,7 @@ template.createCollection(Person.class, CollectionOptions.empty().schema(schema)
}
}
----
<1> Simple object properties are consideres regular properties.
<1> Simple object properties are considers regular properties.
<2> Primitive types are considered required properties
<3> Enums are restricted to possible values.
<4> Object type properties are inspected and represented as nested documents.
Expand All @@ -158,7 +158,7 @@ NOTE: `_id` properties using types that can be converted into `ObjectId` like `S
unless there is more specific information available via the `@MongoId` annotation.

[cols="2,2,6", options="header"]
.Sepcial Schema Generation rules
.Special Schema Generation rules
|===
| Java
| Schema Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ class OrderItem {
this.unitPrice = unitPrice;
}
// getters/setters ommitted
// getters/setters omitted
}
Document input = new Document("id", "4711");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ This method uses class proxies to determine the property.
Make sure that neither the class nor the accessors are `final` as otherwise this approach doesn't work.
====

WARNING: Dot notation (such as `registerConverter(Person.class, "address.street", …)`) for nagivating across properties into subdocuments is *not* supported when registering converters.
WARNING: Dot notation (such as `registerConverter(Person.class, "address.street", …)`) for navigating across properties into subdocuments is *not* supported when registering converters.

TIP: `MongoValueConverter` offers a pre-typed `PropertyValueConverter` interface that uses `MongoConversionContext`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ It is possible to create custom annotations out of the provided ones.
MongoDB Collection Info::
+
====
[source,json,indent=0,subs="verbatim,quotes",role="thrid"]
[source,json,indent=0,subs="verbatim,quotes",role="third"]
----
{
name: 'patient',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function () {
}
----

The follwing reduce function sums up the occurrence of each letter across all the documents:
The following reduce function sums up the occurrence of each letter across all the documents:

[source,java]
----
Expand Down Expand Up @@ -60,7 +60,7 @@ for (ValueObject valueObject : results) {
}
----

The preceding exmaple produces the following output:
The preceding example produces the following output:

[source]
----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ and `Document` (eg. new Document("locale", "en_US"))
NOTE: In case you enabled the automatic index creation for repository finder methods a potential static collation definition,
as shown in (1) and (2), will be included when creating the index.
TIP: The most specifc `Collation` outrules potentially defined others. Which means Method argument over query method annotation over domain type annotation.
TIP: The most specific `Collation` outrules potentially defined others. Which means Method argument over query method annotation over domain type annotation.
====

To streamline usage of collation attributes throughout the codebase it is also possible to use the `@Collation` annotation, which serves as a meta annotation for the ones mentioned above.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ container.register(request, User.class);
container.stop(); <7>
----
<1> Starting the container intializes the resources and starts `Task` instances for already registered `SubscriptionRequest` instances. Requests added after startup are ran immediately.
<1> Starting the container initializes the resources and starts `Task` instances for already registered `SubscriptionRequest` instances. Requests added after startup are ran immediately.
<2> Define the listener called when a `Message` is received. The `Message#getBody()` is converted to the requested domain type. Use `Document` to receive raw results without conversion.
<3> Set the collection to listen to.
<4> Provide an optional filter for documents to receive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ mongoDbFactory.setExceptionTranslator(myCustomExceptionTranslator);
====

A motivation to customize exception can be MongoDB's behavior during transactions where some failures (such as write conflicts) can become transient and where a retry could lead to a successful operation.
In such a case, you could wrap exceptions with a specific MongoDB label and apply a different exception translation stragegy.
In such a case, you could wrap exceptions with a specific MongoDB label and apply a different exception translation strategy.

[[mongo-template.type-mapping]]
== Domain Type Mapping
Expand Down
Loading