Skip to content

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

Closed as not planned
Closed as not planned
@chris-unlikelyai

Description

@chris-unlikelyai

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions