Spring Data Key Value 是否支持派生删除查询方法?它对我不起作用。
我扩展Repository
了,声明了一些CrudRepository
方法,并将这些派生的查询方法添加到其中:
List<ChatMessageEntity> findByChatIdOrderBySequenceNumberAsc(String chatId);
List<ChatMessageEntity> removeByChatId(String chatId);
Long deleteByChatId(String chatId);
除了 2 个派生的删除查询方法外,所有单元测试都通过了。removeByChatId
返回预期列表,但不删除任何内容。deleteByChatId
抛出这个UnsupportedOperationException
:
java.lang.UnsupportedOperationException: Query method not supported.
at org.springframework.data.keyvalue.repository.query.KeyValuePartTreeQuery.execute(KeyValuePartTreeQuery.java:97)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:462)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:440)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
at com.sun.proxy.$Proxy29.deleteByChatId(Unknown Source)
at com.pgi.kcondon.axonminexp.service.ChatRepositoryTest.testRemoveByChatId(ChatRepositoryTest.java:159)
我正在使用 Spring Boot 1.3.3.RELEASE,它依赖于 Spring Data Key Value 1.0.4.RELEASE。