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.
This commit is contained in:
committed by
Mark Paluch
parent
44ed8cfcf2
commit
0c9ea32299
@@ -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
|
||||
include::{spring-data-commons-docs}/entity-callbacks.adoc[leveloffset=+1]
|
||||
|
||||
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.
|
||||
|===============
|
||||
|
||||
[[jdbc.entity-persistence.id-generation]]
|
||||
=== ID Generation
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user