spring data cassandra reactive - custom delete method
up vote
1
down vote
favorite
I am currently trying to specify a delete method in my ReactiveCrudRepository. There ar predefined delete methods which work as expected. But my primary key is named msisdn and not id so i need to define a custom method to delete entries by this key.
This is my approach. notice the Mono return type. it is the same as used by the ReactiveCrudRepository
from spring
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, String> {
Mono<RegistrationEntity> findByMsisdn(String msisdn);
Mono<Void> deleteByMsisdn(String msisdn);
}
I wrote a simple test where test data is persistet in a inmemory cassandra instance and afterwards i try to delete the entry. But i get following exception:
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Void!
at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:79)
at org.springframework.data.cassandra.repository.query.DtoInstantiatingConverter.<init>(DtoInstantiatingConverter.java:64)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingConverter.convert(ReactiveCassandraQueryExecution.java:229)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingExecution.execute(ReactiveCassandraQueryExecution.java:196)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.executeNow(AbstractReactiveCassandraQuery.java:110)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.execute(AbstractReactiveCassandraQuery.java:82)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy45.deleteByMsisdn(Unknown Source)
at ch.sbb.kat.fc.service.CassandraRepositoryTest.deleteTest(CassandraRepositoryTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
Replacing the returntype with Mono does not work. It just returns the object without deleting it.
Am I missing something?
spring spring-data spring-data-cassandra
add a comment |
up vote
1
down vote
favorite
I am currently trying to specify a delete method in my ReactiveCrudRepository. There ar predefined delete methods which work as expected. But my primary key is named msisdn and not id so i need to define a custom method to delete entries by this key.
This is my approach. notice the Mono return type. it is the same as used by the ReactiveCrudRepository
from spring
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, String> {
Mono<RegistrationEntity> findByMsisdn(String msisdn);
Mono<Void> deleteByMsisdn(String msisdn);
}
I wrote a simple test where test data is persistet in a inmemory cassandra instance and afterwards i try to delete the entry. But i get following exception:
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Void!
at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:79)
at org.springframework.data.cassandra.repository.query.DtoInstantiatingConverter.<init>(DtoInstantiatingConverter.java:64)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingConverter.convert(ReactiveCassandraQueryExecution.java:229)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingExecution.execute(ReactiveCassandraQueryExecution.java:196)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.executeNow(AbstractReactiveCassandraQuery.java:110)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.execute(AbstractReactiveCassandraQuery.java:82)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy45.deleteByMsisdn(Unknown Source)
at ch.sbb.kat.fc.service.CassandraRepositoryTest.deleteTest(CassandraRepositoryTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
Replacing the returntype with Mono does not work. It just returns the object without deleting it.
Am I missing something?
spring spring-data spring-data-cassandra
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am currently trying to specify a delete method in my ReactiveCrudRepository. There ar predefined delete methods which work as expected. But my primary key is named msisdn and not id so i need to define a custom method to delete entries by this key.
This is my approach. notice the Mono return type. it is the same as used by the ReactiveCrudRepository
from spring
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, String> {
Mono<RegistrationEntity> findByMsisdn(String msisdn);
Mono<Void> deleteByMsisdn(String msisdn);
}
I wrote a simple test where test data is persistet in a inmemory cassandra instance and afterwards i try to delete the entry. But i get following exception:
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Void!
at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:79)
at org.springframework.data.cassandra.repository.query.DtoInstantiatingConverter.<init>(DtoInstantiatingConverter.java:64)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingConverter.convert(ReactiveCassandraQueryExecution.java:229)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingExecution.execute(ReactiveCassandraQueryExecution.java:196)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.executeNow(AbstractReactiveCassandraQuery.java:110)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.execute(AbstractReactiveCassandraQuery.java:82)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy45.deleteByMsisdn(Unknown Source)
at ch.sbb.kat.fc.service.CassandraRepositoryTest.deleteTest(CassandraRepositoryTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
Replacing the returntype with Mono does not work. It just returns the object without deleting it.
Am I missing something?
spring spring-data spring-data-cassandra
I am currently trying to specify a delete method in my ReactiveCrudRepository. There ar predefined delete methods which work as expected. But my primary key is named msisdn and not id so i need to define a custom method to delete entries by this key.
This is my approach. notice the Mono return type. it is the same as used by the ReactiveCrudRepository
from spring
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, String> {
Mono<RegistrationEntity> findByMsisdn(String msisdn);
Mono<Void> deleteByMsisdn(String msisdn);
}
I wrote a simple test where test data is persistet in a inmemory cassandra instance and afterwards i try to delete the entry. But i get following exception:
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Void!
at org.springframework.data.mapping.context.MappingContext.getRequiredPersistentEntity(MappingContext.java:79)
at org.springframework.data.cassandra.repository.query.DtoInstantiatingConverter.<init>(DtoInstantiatingConverter.java:64)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingConverter.convert(ReactiveCassandraQueryExecution.java:229)
at org.springframework.data.cassandra.repository.query.ReactiveCassandraQueryExecution$ResultProcessingExecution.execute(ReactiveCassandraQueryExecution.java:196)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.executeNow(AbstractReactiveCassandraQuery.java:110)
at org.springframework.data.cassandra.repository.query.AbstractReactiveCassandraQuery.execute(AbstractReactiveCassandraQuery.java:82)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy45.deleteByMsisdn(Unknown Source)
at ch.sbb.kat.fc.service.CassandraRepositoryTest.deleteTest(CassandraRepositoryTest.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
Replacing the returntype with Mono does not work. It just returns the object without deleting it.
Am I missing something?
spring spring-data spring-data-cassandra
spring spring-data spring-data-cassandra
asked Nov 8 at 11:50
locohost
235
235
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
My solution is to use a MapId
instead of String
:
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {
}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
My solution is to use a MapId
instead of String
:
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {
}
add a comment |
up vote
0
down vote
accepted
My solution is to use a MapId
instead of String
:
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {
}
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
My solution is to use a MapId
instead of String
:
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {
}
My solution is to use a MapId
instead of String
:
public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {
}
answered Nov 21 at 11:11
locohost
235
235
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53207172%2fspring-data-cassandra-reactive-custom-delete-method%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown