Browse Source

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.

Closes: #951.
pull/1035/head
Jens Schauder 5 years ago committed by Mark Paluch
parent
commit
0c9ea32299
No known key found for this signature in database
GPG Key ID: 4406B84C1661DCD1
  1. 19
      src/main/asciidoc/jdbc.adoc

19
src/main/asciidoc/jdbc.adoc

@ -430,21 +430,8 @@ Embedded entities containing a `Collection` or a `Map` will always be considered @@ -430,21 +430,8 @@ Embedded entities containing a `Collection` or a `Map` will always be considered
Such an entity will therefore never be `null` even when using @Embedded(onEmpty = USE_NULL).
[[jdbc.entity-persistence.state-detection-strategies]]
=== Entity State Detection Strategies
The following table describes the strategies that Spring Data JDBC offers for detecting whether an entity is new:
.Options for detection whether an entity is new in Spring Data JDBC
[options = "autowidth"]
|===============
|Id-Property inspection (the default)|By default, Spring Data JDBC 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 to not be new.
|Implementing `Persistable`|If an entity implements `Persistable`, Spring Data JDBC 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.
|Implementing `EntityInformation`|You can customize the `EntityInformation` abstraction used in the `SimpleJdbcRepository` implementation by creating a subclass of `JdbcRepositoryFactory` and overriding the `getEntityInformation(…)` method.
You then have to register the custom implementation of `JdbcRepositoryFactory` as a Spring bean.
Note that this should rarely be necessary. See the link:{javadoc-base}org/springframework/data/jdbc/repository/support/JdbcRepositoryFactory.html[Javadoc] for details.
|===============
include::{spring-data-commons-docs}/entity-callbacks.adoc[leveloffset=+1]
[[jdbc.entity-persistence.id-generation]]
=== ID Generation
@ -889,7 +876,7 @@ The following table describes the available events: @@ -889,7 +876,7 @@ The following table describes the available events:
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::{spring-data-commons-docs}/is-new-state-detection.adoc[leveloffset=+2]
[[jdbc.entity-callbacks]]
=== Store-specific EntityCallbacks

Loading…
Cancel
Save