Skip to content

Method name-based delete operations don't delete #1965

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
chris-unlikelyai opened this issue Dec 30, 2024 · 1 comment
Closed

Method name-based delete operations don't delete #1965

chris-unlikelyai opened this issue Dec 30, 2024 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@chris-unlikelyai
Copy link

The docs seem to suggest I can define a custom delete method on my repository in the same way I can define a custom query method. For example:

@Table
data class Entity(val name: String, @Id val id: UUID? = null)

interface EntityRepository : CrudRepository<Entity, UUID> {
  fun deleteByName(name: String)
}

However, calling the method doesn't delete anything. Enabling debug logging for Spring Data, it looks like Spring is attempting to query instead of delete:

SELECT "ENTITY"."ID" AS "ID", "ENTITY"."NAME" AS "NAME" FROM "ENTITY" WHERE "ENTITY"."NAME" = ?

Is this actually supported? The docs are slightly vague in the sense that they only really mention it in passing.

Reproducable example: https://github.com/chris-unlikelyai/springdataissue2

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 30, 2024
@schauder
Copy link
Contributor

schauder commented Jan 2, 2025

You are referring to the general section of the documentation, describing the general behaviour of Spring Data modules.
Not everything described there is fully supported by all modules.
And delete for query derivation is indeed not supported in the current version of Spring Data.

The good news is a PR was recently merged, implementing this support. So this feature will be available in version 3.5M1 and following.

@schauder schauder closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
@schauder schauder added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants