Skip to content

Commit 668c335

Browse files
committed
Refine entity state detection wording using primitive versions.
Closes #3798
1 parent 4cb6518 commit 668c335

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/main/antora/modules/ROOT/pages/jpa/entity-persistence.adoc

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Spring Data JPA offers the following strategies to detect whether an entity is n
1818
Without such a Version-property Spring Data JPA inspects the identifier property of the given entity.
1919
If the identifier property is `null`, then the entity is assumed to be new.
2020
Otherwise, it is assumed to be not new.
21+
In contrast to other Spring Data modules, JPA considers `0` (zero) as the first inserted version of an entity and therefore, a primitive version property cannot be used to determine whether an entity is new or not.
2122
2. Implementing `Persistable`: If an entity implements `Persistable`, Spring Data JPA 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.
2223
3. Implementing `EntityInformation`: You can customize the `EntityInformation` abstraction used in the `SimpleJpaRepository` implementation by creating a subclass of `JpaRepositoryFactory` and overriding the `getEntityInformation(…)` method accordingly. You then have to register the custom implementation of `JpaRepositoryFactory` as a Spring bean. Note that this should be rarely necessary. See the javadoc:org.springframework.data.jpa.repository.support.JpaRepositoryFactory[JavaDoc] for details.
2324

0 commit comments

Comments
 (0)