Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-2633

@Query annotation does not support $centerSphere

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.4 (Neumann SR4)
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Mac os Catalina 10.15.4 (19E266)
      Spring Boot 2.3.4
      TestContainers
      MongoDb 4.4.1
      openjdk 11.0.6 2020-01-14

      Description

      I want to create a geospatial query in a ReactiveMongoRepository, and use following functions :

      • $geoWithin
      • $centerSphere
      @Query("{'stores.location' : { $geoWithin: { $centerSphere: [ [ 1.948516, 48.799029 ] , 0.004 ] } } }")

      But unfortunately i'am getting a runtime error : 

      ReadEndArray can only be called when State is END_OF_ARRAY, not when State is VALUE.ReadEndArray can only be called when State is END_OF_ARRAY, not when State is VALUE.org.bson.BsonInvalidOperationException: ReadEndArray can only be called when State is END_OF_ARRAY, not when State is VALUE. at org.bson.AbstractBsonReader.throwInvalidState(AbstractBsonReader.java:669) at org.bson.AbstractBsonReader.readEndArray(AbstractBsonReader.java:334) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.readList(ParameterBindingDocumentCodec.java:349) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.readValue(ParameterBindingDocumentCodec.java:317) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:200) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:62) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.readValue(ParameterBindingDocumentCodec.java:331) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:200) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:62) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.readValue(ParameterBindingDocumentCodec.java:331) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:200) at org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec.decode(ParameterBindingDocumentCodec.java:176) at org.springframework.data.mongodb.repository.query.ReactiveStringBasedMongoQuery.createQuery(ReactiveStringBasedMongoQuery.java:122) at org.springframework.data.mongodb.repository.query.AbstractReactiveMongoQuery.doExecute(AbstractReactiveMongoQuery.java:147) at org.springframework.data.mongodb.repository.query.AbstractReactiveMongoQuery.execute(AbstractReactiveMongoQuery.java:132) at org.springframework.data.mongodb.repository.query.AbstractReactiveMongoQuery.execute(AbstractReactiveMongoQuery.java:104) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor$QueryMethodInvoker.invoke(QueryExecutorMethodInterceptor.java:195) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:152) at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:130) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy103.byCenterSphere(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) at com.sun.proxy.$Proxy103.byCenterSphere(Unknown Source)
      

      I can add the same is working with ReactiveMongoTemplate :

      BasicQuery query = new BasicQuery("{'stores.location' : { $geoWithin: { $centerSphere: [ [ 1.948516, 48.799029 ] , 0.004 ] } } }");
      final Flux<Provider> actual = reactiveMongoTemplate.find(query, Pojo.class);
      

      Thank you

        Attachments

          Activity

            People

            Assignee:
            cstrobl Christoph Strobl
            Reporter:
            hkka hkka
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: