Skip to content

Commit eb42ed5

Browse files
committed
Include Entity-state detection documentation snipped from Commons.
Closes #579
1 parent 3ce65fa commit eb42ed5

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,7 @@ Extensions are retrieved from the application context at the time of SpEL evalua
280280
TIP: When using SpEL expressions in combination with plain parameters, use named parameter notation instead of native bind markers to ensure a proper binding order.
281281

282282
[[r2dbc.entity-persistence.state-detection-strategies]]
283-
=== Entity State Detection Strategies
284-
285-
The following table describes the strategies that Spring Data R2DBC offers for detecting whether an entity is new:
286-
287-
.Options for detection whether an entity is new in Spring Data R2DBC
288-
[options = "autowidth"]
289-
|===============
290-
|Id-Property inspection (the default) |By default, the `save()` method inspects the identifier property of the given entity.
291-
If the identifier property is `null`, then the entity is assumed to be new. Otherwise, it is assumed exist in the datbase.
292-
|Implementing `Persistable` |If an entity implements `Persistable`, Spring Data R2DBC delegates the new detection to the `isNew(…)` method of the entity.
293-
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.
294-
|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.
295-
|Implementing `EntityInformation` |You can customize the `EntityInformation` abstraction used in `SimpleR2dbcRepository` by creating a subclass of `R2dbcRepositoryFactory` and overriding `getEntityInformation(…)`.
296-
You then have to register the custom implementation of `R2dbcRepositoryFactory` as a Spring bean.
297-
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.
298-
|===============
283+
include::../{spring-data-commons-docs}/is-new-state-detection.adoc[leveloffset=+2]
299284

300285
[[r2dbc.entity-persistence.id-generation]]
301286
=== ID Generation

0 commit comments

Comments
 (0)