From 635f30a8655fe99cfd42616f99e340d0cc37b539 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 13 Apr 2021 15:20:39 +0200 Subject: [PATCH] Include Entity-state detection documentation snipped from Commons. Closes #579 --- .../asciidoc/reference/r2dbc-repositories.adoc | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/main/asciidoc/reference/r2dbc-repositories.adoc b/src/main/asciidoc/reference/r2dbc-repositories.adoc index 4365f7f0f..44a7b1769 100644 --- a/src/main/asciidoc/reference/r2dbc-repositories.adoc +++ b/src/main/asciidoc/reference/r2dbc-repositories.adoc @@ -321,22 +321,7 @@ Query By Example really shines when you you don't know all the fields needed in If you were building a filter on a web page where the user can pick the fields, Query By Example is a great way to flexibly capture that into an efficient query. [[r2dbc.entity-persistence.state-detection-strategies]] -=== Entity State Detection Strategies - -The following table describes the strategies that Spring Data R2DBC offers for detecting whether an entity is new: - -.Options for detection whether an entity is new in Spring Data R2DBC -[options = "autowidth"] -|=============== -|Id-Property inspection (the default) |By default, the `save()` method inspects the identifier property of the given entity. -If the identifier property is `null`, then the entity is assumed to be new. Otherwise, it is assumed exist in the datbase. -|Implementing `Persistable` |If an entity implements `Persistable`, Spring Data R2DBC delegates the new detection to the `isNew(…)` method of the entity. -See the link:$$https://docs.spring.io/spring-data/data-commons/docs/current/api/index.html?org/springframework/data/domain/Persistable.html$$[Javadoc] for details. -|Optimistic Locking through `@Version` | If an entity uses Optimistic Locking by (version property annotated with `@Version`), Spring Data R2DBC checks if the entity is new by inspecting the version property whether its value corresponds with Java's default initialization value. That is `0` for primitive types and `null` for wrapper types. -|Implementing `EntityInformation` |You can customize the `EntityInformation` abstraction used in `SimpleR2dbcRepository` by creating a subclass of `R2dbcRepositoryFactory` and overriding `getEntityInformation(…)`. -You then have to register the custom implementation of `R2dbcRepositoryFactory` as a Spring bean. -Note that this should rarely be necessary. See the link:{spring-data-r2dbc-javadoc}/org/springframework/data/r2dbc/repository/support/R2dbcRepositoryFactory.html[Javadoc] for details. -|=============== +include::../{spring-data-commons-docs}/is-new-state-detection.adoc[leveloffset=+2] [[r2dbc.entity-persistence.id-generation]] === ID Generation