Skip to content

Improve documentation for deleteById. #3281

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 1 commit 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
Improve documentation for deleteById.
The documentation now clarifies that entity might get loaded and therefore possibly OptimisticLockingFailureException might get thrown.

Closes #3280
  • Loading branch information
schauder committed Apr 29, 2025
commit 80a1a928e75d85eb92f4e0a57e1f4885d27c83ca
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-commons</artifactId>
<version>3.5.0-SNAPSHOT</version>
<version>3.5.0-repository-optimistic-locking-SNAPSHOT</version>

<name>Spring Data Core</name>
<description>Core Spring concepts underpinning every Spring Data module.</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
import org.springframework.dao.OptimisticLockingFailureException;

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