DATAMONGO-2261 - Adapt to changes in DATACMNS-1467.

Use the reworked version of the EntityCallback method lookup.
Also fix issues with callbacks not invoked when intended and rework the reactive flow by removing deeply nested constructs.
Update documentation and add EntityCallbacks to BulkOperations.

Original Pull Request: #742
This commit is contained in:
Christoph Strobl
2019-05-29 08:30:07 +02:00
parent 45bd6d544d
commit a7e6b26796
13 changed files with 735 additions and 90 deletions

View File

@@ -0,0 +1,30 @@
= Store specific EntityCallbacks
Spring Data MongoDB uses the `EntityCallback` API for its auditing support and reacts on the following callbacks.
.Supported Entity Callbacks
[%header,cols="4"]
|===
| Callback
| Method
| Description
| Order
| Reactive/BeforeConvertCallback
| onBeforeConvert(T entity, String collection)
| Invoked before a domain object is converted to `org.bson.Document`.
| `Ordered.LOWEST_PRECEDENCE`
| Reactive/AuditingEntityCallback
| onBeforeConvert(Object entity, String collection)
| Marks an auditable entity _created_ or _modified_
| 100
| Reactive/BeforeSaveCallback
| onBeforeSave(T entity, org.bson.Document target, String collection)
| Invoked before a domain object is saved. +
Can modify the target, to be persisted, `Document` containing all mapped entity information.
| `Ordered.LOWEST_PRECEDENCE`
|===

View File

@@ -3159,6 +3159,11 @@ The following callback methods are present in `AbstractMappingEventListener`:
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`.
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.
include::../{spring-data-commons-docs}/entity-callbacks.adoc[leveloffset=+1]
include::./mongo-entity-callbacks.adoc[leveloffset=+2]
[[mongo.exception]]
== Exception Translation