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?










share|improve this question


























    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?










    share|improve this question
























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 11:50









      locohost

      235




      235
























          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> {

          }





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            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

























            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> {

            }





            share|improve this answer

























              up vote
              0
              down vote



              accepted










              My solution is to use a MapId instead of String
              :



              public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {

              }





              share|improve this answer























                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> {

                }





                share|improve this answer












                My solution is to use a MapId instead of String
                :



                public interface RegistrationRepository extends ReactiveCrudRepository<RegistrationEntity, MapId> {

                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 at 11:11









                locohost

                235




                235






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Xamarin.iOS Cant Deploy on Iphone

                    Glorious Revolution

                    Dulmage-Mendelsohn matrix decomposition in Python