spring-projects / spring-projects/spring-data-redis
Add support for deleteBy/removeBy queries
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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