Skip to content

Commit 7c50f99

Browse files
mp911dechristophstrobl
authored andcommitted
Restructure documentation.
Move examples into test source root to ensure proper compilation. Remove lingering asciidoc resources. Merge entity callbacks into lifecycle events. Add links from MongoDB overview. See: #4497
1 parent 5acb174 commit 7c50f99

32 files changed

+1114
-1130
lines changed

src/main/antora/modules/ROOT/examples/MongoApplication.java renamed to spring-data-mongodb/src/test/java/org/springframework/data/mongodb/example/MongoApplication.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@
1616
// tag::file[]
1717
package org.springframework.data.mongodb.example;
1818

19-
import static org.springframework.data.mongodb.core.query.Criteria.where;
20-
import static org.springframework.data.mongodb.core.query.Query.query;
19+
import static org.springframework.data.mongodb.core.query.Criteria.*;
2120

2221
import org.springframework.data.mongodb.core.MongoOperations;
2322
import org.springframework.data.mongodb.core.MongoTemplate;
24-
import org.springframework.data.mongodb.core.query.Query;
2523

2624
import com.mongodb.client.MongoClients;
2725

src/main/antora/modules/ROOT/examples/ReactiveMongoApplication.java renamed to spring-data-mongodb/src/test/java/org/springframework/data/mongodb/example/ReactiveMongoApplication.java

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.data.mongodb.example;
1818

1919
import static org.springframework.data.mongodb.core.query.Criteria.*;
20-
import static org.springframework.data.mongodb.core.query.Query.*;
2120

2221
import org.springframework.data.mongodb.core.ReactiveMongoOperations;
2322
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
Binary file not shown.

src/main/antora/modules/ROOT/assets/images/epub-cover.svg

-12
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../../spring-data-mongodb/src/test/java/org/springframework/data/mongodb/example

src/main/antora/modules/ROOT/nav.adoc

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,40 @@
77
* xref:mongodb.adoc[]
88
** xref:mongodb/getting-started.adoc[]
99
** xref:mongodb/configuration.adoc[]
10+
1011
** xref:mongodb/template-api.adoc[]
1112
*** xref:mongodb/template-config.adoc[]
13+
*** xref:mongodb/template-collection-management.adoc[]
1214
*** xref:mongodb/template-crud-operations.adoc[]
1315
*** xref:mongodb/template-query-operations.adoc[]
14-
**** xref:mongodb/template-query-options.adoc[]
15-
*** xref:mongodb/template-document-count.adoc[]
1616
*** xref:mongodb/aggregation-framework.adoc[]
17-
*** xref:mongodb/template-collection-management.adoc[]
18-
**** xref:mongodb/template-collection-schema.adoc[]
19-
*** xref:mongodb/template-gridfs.adoc[]
17+
*** xref:mongodb/template-document-count.adoc[]
18+
19+
** xref:mongodb/template-gridfs.adoc[]
2020
** xref:mongodb/mapping/mapping.adoc[]
21+
*** xref:mongodb/mapping/mapping-schema.adoc[]
2122
*** xref:mongodb/mapping/custom-conversions.adoc[Type based Converter]
2223
*** xref:mongodb/mapping/property-converters.adoc[]
2324
*** xref:mongodb/mapping/unwrapping-entities.adoc[]
2425
*** xref:mongodb/mapping/document-references.adoc[Object References]
25-
*** xref:mongodb/mapping/entity-callbacks.adoc[Entity Callbacks]
26-
*** xref:mongodb/mapping/lifecycle-events.adoc[]
2726
*** xref:mongodb/mapping/mapping-index-management.adoc[]
27+
28+
** xref:mongodb/lifecycle-events.adoc[]
29+
** xref:mongodb/auditing.adoc[]
2830
** xref:mongodb/client-session-transactions.adoc[]
2931
** xref:mongodb/change-streams.adoc[]
3032
** xref:mongodb/tailable-cursors.adoc[]
3133
** xref:mongodb/sharding.adoc[]
3234
** xref:mongodb/mongo-encryption.adoc[]
33-
** xref:mongodb/auditing.adoc[]
3435

3536
// Repository
3637
* xref:repositories.adoc[]
3738
** xref:repositories/core-concepts.adoc[]
3839
** xref:repositories/definition.adoc[]
3940
** xref:mongodb/repositories/repositories.adoc[]
40-
*** xref:mongodb/repositories/repositories-index-hints.adoc[]
41-
*** xref:mongodb/repositories/repositories-collation.adoc[]
4241
** xref:repositories/create-instances.adoc[]
4342
** xref:repositories/query-methods-details.adoc[]
43+
** xref:mongodb/repositories/query-methods.adoc[]
4444
** xref:repositories/projections.adoc[]
4545
** xref:repositories/custom-implementations.adoc[]
4646
** xref:repositories/core-domain-events.adoc[]

src/main/antora/modules/ROOT/pages/kotlin/object-mapping.adoc

-1
This file was deleted.

src/main/antora/modules/ROOT/pages/mongodb.adoc

+12-11
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44

55
Spring Data support for MongoDB contains a wide range of features:
66

7-
* Spring configuration support with Java-based `@Configuration` classes or an XML namespace for a Mongo driver instance and replica sets.
8-
* `MongoTemplate` helper class that increases productivity when performing common Mongo operations. Includes integrated object mapping between documents and POJOs.
9-
* Exception translation into Spring's portable Data Access Exception hierarchy.
10-
* Feature-rich Object Mapping integrated with Spring's Conversion Service.
11-
* Annotation-based mapping metadata that is extensible to support other metadata formats.
12-
* Persistence and mapping lifecycle events.
13-
* Java-based Query, Criteria, and Update DSLs.
14-
* Automatic implementation of Repository interfaces, including support for custom finder methods.
15-
* QueryDSL integration to support type-safe queries.
16-
* Multi Document Transactions.
17-
* GeoSpatial integration.
7+
* xref:mongodb/template-config.adoc[Spring configuration support] with Java-based `@Configuration` classes or an XML namespace for a Mongo driver instance and replica sets.
8+
* xref:mongodb/template-api.adoc[`MongoTemplate` helper class] that increases productivity when performing common Mongo operations.
9+
Includes integrated object mapping between documents and POJOs.
10+
* xref:mongodb/template-api.adoc#mongo-template.exception-translation[Exception translation] into Spring's portable Data Access Exception hierarchy.
11+
* Feature-rich xref:mongodb/mapping/mapping.adoc[Object Mapping] integrated with Spring's Conversion Service.
12+
* xref:mongodb/mapping/mapping.adoc#mapping-usage-annotations[Annotation-based mapping metadata] that is extensible to support other metadata formats.
13+
* xref:mongodb/lifecycle-events.adoc[Persistence and mapping lifecycle events].
14+
* xref:mongodb/template-query-operations.adoc[Java-based Query, Criteria, and Update DSLs].
15+
* Automatic implementation of xref:repositories.adoc[Repository interfaces], including support for custom query methods.
16+
* xref:mongodb/repositories/repositories.adoc#mongodb.repositories.queries.type-safe[QueryDSL integration] to support type-safe queries.
17+
* xref:mongodb/client-session-transactions.adoc[Multi-Document Transactions].
18+
* xref:mongodb/template-query-operations.adoc#mongo.geo-json[GeoSpatial integration].
1819

1920
For most tasks, you should use `MongoTemplate` or the Repository support, which both leverage the rich mapping functionality.
2021
`MongoTemplate` is the place to look for accessing functionality such as incrementing counters or ad-hoc CRUD operations.

src/main/antora/modules/ROOT/pages/mongodb/getting-started.adoc

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Then you can create a `Person` class to persist:
1919
====
2020
[source,java]
2121
----
22-
include::example$Person.java[tags=file]
22+
include::example$example/Person.java[tags=file]
2323
----
2424
====
2525

@@ -31,14 +31,14 @@ Imperative::
3131
+
3232
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
3333
----
34-
include::example$MongoApplication.java[tags=file]
34+
include::example$example/MongoApplication.java[tags=file]
3535
----
3636
3737
Reactive::
3838
+
3939
[source,java,indent=0,subs="verbatim,quotes",role="secondary"]
4040
----
41-
include::example$ReactiveMongoApplication.java[tags=file]
41+
include::example$example/ReactiveMongoApplication.java[tags=file]
4242
----
4343
======
4444

src/main/antora/modules/ROOT/pages/mongodb/mapping/lifecycle-events.adoc renamed to src/main/antora/modules/ROOT/pages/mongodb/lifecycle-events.adoc

+51-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,58 @@ Declaring these beans in your Spring ApplicationContext causes them to be invoke
4949
* `onAfterConvert`: Called in `MongoTemplate` `find`, `findAndRemove`, `findOne`, and `getCollection` methods after the `Document` has been retrieved from the database was converted to a POJO.
5050
====
5151

52-
NOTE: Lifecycle events are only emitted for root level types. Complex types used as properties within a document root are not subject to event publication unless they are document references annotated with `@DBRef`.
52+
NOTE: Lifecycle events are only emitted for root level types.
53+
Complex types used as properties within a document root are not subject to event publication unless they are document references annotated with `@DBRef`.
5354

5455
WARNING: Lifecycle events depend on an `ApplicationEventMulticaster`, which in case of the `SimpleApplicationEventMulticaster` can be configured with a `TaskExecutor`, and therefore gives no guarantees when an Event is processed.
5556

57+
include::{commons}@data-commons::page$entity-callbacks.adoc[leveloffset=+1]
58+
59+
[[mongo.entity-callbacks]]
60+
== Store specific EntityCallbacks
61+
62+
Spring Data MongoDB uses the `EntityCallback` API for its auditing support and reacts on the following callbacks.
63+
64+
.Supported Entity Callbacks
65+
[%header,cols="4"]
66+
|===
67+
| Callback
68+
| Method
69+
| Description
70+
| Order
71+
72+
| `ReactiveBeforeConvertCallback`
73+
`BeforeConvertCallback`
74+
| `onBeforeConvert(T entity, String collection)`
75+
| Invoked before a domain object is converted to `org.bson.Document`.
76+
| `Ordered.LOWEST_PRECEDENCE`
77+
78+
| `ReactiveAfterConvertCallback`
79+
`AfterConvertCallback`
80+
| `onAfterConvert(T entity, org.bson.Document target, String collection)`
81+
| Invoked after a domain object is loaded. +
82+
Can modify the domain object after reading it from a `org.bson.Document`.
83+
| `Ordered.LOWEST_PRECEDENCE`
84+
85+
| `ReactiveAuditingEntityCallback`
86+
`AuditingEntityCallback`
87+
| `onBeforeConvert(Object entity, String collection)`
88+
| Marks an auditable entity _created_ or _modified_
89+
| 100
90+
91+
| `ReactiveBeforeSaveCallback`
92+
`BeforeSaveCallback`
93+
| `onBeforeSave(T entity, org.bson.Document target, String collection)`
94+
| Invoked before a domain object is saved. +
95+
Can modify the target, to be persisted, `Document` containing all mapped entity information.
96+
| `Ordered.LOWEST_PRECEDENCE`
97+
98+
| `ReactiveAfterSaveCallback`
99+
`AfterSaveCallback`
100+
| `onAfterSave(T entity, org.bson.Document target, String collection)`
101+
| Invoked before a domain object is saved. +
102+
Can modify the domain object, to be returned after save, `Document` containing all mapped entity information.
103+
| `Ordered.LOWEST_PRECEDENCE`
104+
105+
|===
56106

src/main/antora/modules/ROOT/pages/mongodb/mapping/custom-conversions.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class Payment {
3030
"date" : ISODate("2019-04-03T12:11:01.870Z") <3>
3131
}
3232
----
33-
<1> String _id_ values that represent a valid `ObjectId` are converted automatically. See xref:mongodb/template-id-handling.adoc#mongo-template.id-handling[How the `_id` Field is Handled in the Mapping Layer]
33+
<1> String _id_ values that represent a valid `ObjectId` are converted automatically. See xref:mongodb/template-crud-operations.adoc#mongo-template.id-handling[How the `_id` Field is Handled in the Mapping Layer]
3434
for details.
3535
<2> The desired target type is explicitly defined as `Decimal128` which translates to `NumberDecimal`. Otherwise the
3636
`BigDecimal` value would have been truned into a `String`.

0 commit comments

Comments
 (0)