Skip to content

Commit 635f30a

Browse files
committed
Include Entity-state detection documentation snipped from Commons.
Closes #579
1 parent 5397152 commit 635f30a

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

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

+1-16
Original file line numberDiff line numberDiff line change
@@ -321,22 +321,7 @@ Query By Example really shines when you you don't know all the fields needed in
321321
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.
322322

323323
[[r2dbc.entity-persistence.state-detection-strategies]]
324-
=== Entity State Detection Strategies
325-
326-
The following table describes the strategies that Spring Data R2DBC offers for detecting whether an entity is new:
327-
328-
.Options for detection whether an entity is new in Spring Data R2DBC
329-
[options = "autowidth"]
330-
|===============
331-
|Id-Property inspection (the default) |By default, the `save()` method inspects the identifier property of the given entity.
332-
If the identifier property is `null`, then the entity is assumed to be new. Otherwise, it is assumed exist in the datbase.
333-
|Implementing `Persistable` |If an entity implements `Persistable`, Spring Data R2DBC delegates the new detection to the `isNew(…)` method of the entity.
334-
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.
335-
|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.
336-
|Implementing `EntityInformation` |You can customize the `EntityInformation` abstraction used in `SimpleR2dbcRepository` by creating a subclass of `R2dbcRepositoryFactory` and overriding `getEntityInformation(…)`.
337-
You then have to register the custom implementation of `R2dbcRepositoryFactory` as a Spring bean.
338-
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.
339-
|===============
324+
include::../{spring-data-commons-docs}/is-new-state-detection.adoc[leveloffset=+2]
340325

341326
[[r2dbc.entity-persistence.id-generation]]
342327
=== ID Generation

0 commit comments

Comments
 (0)