Skip to content

Commit 80a1a92

Browse files
committed
Improve documentation for deleteById.
The documentation now clarifies that entity might get loaded and therefore possibly OptimisticLockingFailureException might get thrown. Closes #3280
1 parent e17dd32 commit 80a1a92

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>org.springframework.data</groupId>
77
<artifactId>spring-data-commons</artifactId>
8-
<version>3.5.0-SNAPSHOT</version>
8+
<version>3.5.0-repository-optimistic-locking-SNAPSHOT</version>
99

1010
<name>Spring Data Core</name>
1111
<description>Core Spring concepts underpinning every Spring Data module.</description>

src/main/java/org/springframework/data/repository/CrudRepository.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@
2020
import org.springframework.dao.OptimisticLockingFailureException;
2121

2222
/**
23-
* Interface for generic CRUD operations on a repository for a specific type.
24-
*
23+
* Interface for generic CRUD operations on a repository for a specific type. In general operations offered via this
24+
* interface participate in life cycle events, and optimistic locking. Therefore, modules may choose to load an entity
25+
* before deleting or updating it in order to facilitate this, and any modifying method call may trigger an exception
26+
* due to failure of optimistic locking.
27+
*
2528
* @author Oliver Gierke
2629
* @author Eberhard Wolff
2730
* @author Jens Schauder
@@ -106,7 +109,11 @@ public interface CrudRepository<T, ID> extends Repository<T, ID> {
106109
* Deletes the entity with the given id.
107110
* <p>
108111
* If the entity is not found in the persistence store it is silently ignored.
109-
*
112+
* <p>
113+
* Note that, since this method triggers life cycle events, it might need to load an entity before deleting it. This
114+
* also might trigger {@link OptimisticLockingFailureException} if between loading and actually deleting the entity,
115+
* the entity was changed by some other process.
116+
*
110117
* @param id must not be {@literal null}.
111118
* @throws IllegalArgumentException in case the given {@literal id} is {@literal null}
112119
*/

0 commit comments

Comments
 (0)