You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.UnsupportedOperationException: Query method not supported
at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.doExecute(KeyValuePartTreeQuery.java:145)
at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:111)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:170)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:158)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:164)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:143)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:220)
at jdk.proxy2/jdk.proxy2.$Proxy60.findByName(Unknown Source)
at ir.co.rrr.testredis.FruitRepositoryTest.testGetProjectionFruit(FruitRepositoryTest.java:20)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Here is my test code:
@Getter
@AllArgsConstructor
@RedisHash("Fruit")
public class Fruit {
@Id
private Integer id;
@Indexed
private String name;
private String description;
}
public interface FruitProjection {
String getName();
}
public interface FruitRepository extends CrudRepository<Fruit, Integer> {
FruitProjection findProjectionById(Integer id);
FruitProjection findByName(String name);
}
My test:
@SpringBootTest
class FruitRepositoryTest {
@Autowired
FruitRepository fruitRepository;
@Test
void testGetProjectionFruit() {
Fruit banana = new Fruit(1, "Banana", "Yellow and long");
Fruit saved = fruitRepository.save(banana);
Assertions.assertThat(saved).isNotNull();
FruitProjection projectionByName = fruitRepository.findByName("Banana");
Assertions.assertThat(projectionByName).isNotNull();
FruitProjection projectionById = fruitRepository.findProjectionById(1);
Assertions.assertThat(projectionById).isNotNull();
}
}
No other configuration or properties has been set for this project.
Using Spring boot 3.2.2.
Notes:
Both findByName and findProjectionById throw exception
Event without an indexed column (@Indexed), findProjectionById throws an excpetion.
The text was updated successfully, but these errors were encountered:
There are two issues. First, KeyValuePartTreeQuery doesn't allow queries that return a type different than the domain type, see spring-projects/spring-data-keyvalue#563. Secondly, the query by ID falls back to an index search.
The projection issue needs to be addressed in Spring Data KeyValue. I'm changing this ticket to fall back to by-id queries if the query uses a by-id constraint.
mp911de
changed the title
Redis Repositories with projections throws Query method not supported
Redis Repositories do not find results for custom find…ById(…) queries
Feb 20, 2024
Hello
Based on the link in documentations, https://docs.spring.io/spring-data/redis/reference/repositories/projections.html, I suppose that projections are supported with Redis repositories.
However I've written a small test application and it throws:
Here is my test code:
My test:
No other configuration or properties has been set for this project.
Using Spring boot 3.2.2.
Notes:
findByName
andfindProjectionById
throw exception@Indexed
),findProjectionById
throws an excpetion.The text was updated successfully, but these errors were encountered: