Skip to content

Improve documentation of entity state detection #951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Spring Data Relational Parent</name>
Expand Down
2 changes: 1 addition & 1 deletion spring-data-jdbc-distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions spring-data-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-jdbc</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>

<name>Spring Data JDBC</name>
<description>Spring Data module for JDBC repositories.</description>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>
</parent>

<properties>
Expand Down
4 changes: 2 additions & 2 deletions spring-data-relational/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<modelVersion>4.0.0</modelVersion>

<artifactId>spring-data-relational</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>

<name>Spring Data Relational</name>
<description>Spring Data Relational support</description>

<parent>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-relational-parent</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-version-doc-SNAPSHOT</version>
</parent>

<properties>
Expand Down
19 changes: 3 additions & 16 deletions src/main/asciidoc/jdbc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down