spring-projects / spring-projects/spring-data-redis

Add support for deleteBy/removeBy queries

Open
#2,149 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement
Dominant language
Java
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Since 2014, core Spring Data JPA has supported deleteBy/removeBy in queries, just like findBy queries. However, Spring Data Redis does not support this, instead throwing

java.lang.UnsupportedOperationException: Query method not supported.
	at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.doExecute(KeyValuePartTreeQuery.java:144)
	at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:110)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
	at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
	at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at com.sun.proxy.$Proxy115.deleteByRecordingSid(Unknown Source)

I would like to request that deleteBy (and its synonym removeBy) be supported in queries.

Code Example

@RedisHash("Student")
public class Student {

    @Id
    private String id;
    @Indexed
    private String name;

    // Getters and setters
}
@Repository
public interface StudentRepository extends CrudRepository<Student, String> {

    Student findByName(String name);

    void deleteByName(String name);
}
studentRepository.findByName("John Doe"); // Successful
studentRepository.deleteByName("John Doe"); // UnsupportedOperationException

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.java at doExecute, the entry point named in the stack trace, and compare its handling with the StudentRepository example. Done means derived deleteBy and removeBy methods execute successfully and remove matching Redis entities instead of throwing UnsupportedOperationException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.