Skip to content

Commit 6968c90

Browse files
committed
Improve documentation of entity state detection.
The use of a version property to determine the state of an entity wasn't properly documented so far. Related tickets spring-projects/spring-data-commons#2338
1 parent 72a2049 commit 6968c90

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/asciidoc/jdbc.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,11 @@ The following table describes the strategies that Spring Data JDBC offers for de
437437
.Options for detection whether an entity is new in Spring Data JDBC
438438
[options = "autowidth"]
439439
|===============
440-
|Id-Property inspection (the default)|By default, Spring Data JDBC inspects the identifier property of the given entity.
441-
If the identifier property is `null`, then the entity is assumed to be new. Otherwise, it is assumed to not be new.
440+
|Id-Property inspection (the default)|By default, Spring Data JDBC inspects the version property of the given entity.
441+
If the identifier property is `null` or `0` in case of primitve types, then the entity is assumed to be new. Otherwise, it is assumed to not be new.
442+
|Version-Property inspection|If a property annotated with `@Version` is present and `null`, or in case of a version property of primitive type `0` the entity is considered new.
443+
If the version property is present but has a different value, the entity is considered not new.
444+
If no version property is present Spring Data JDBC falls back to inspection of the Id-Property.
442445
|Implementing `Persistable`|If an entity implements `Persistable`, Spring Data JDBC delegates the new detection to the `isNew(…)` method of the entity.
443446
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.
444447
|Implementing `EntityInformation`|You can customize the `EntityInformation` abstraction used in the `SimpleJdbcRepository` implementation by creating a subclass of `JdbcRepositoryFactory` and overriding the `getEntityInformation(…)` method.

0 commit comments

Comments
 (0)