【问题标题】:Exception:rg.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException: Unable to convert class PageRequest to Datastore异常:org.springframework.cloud.gcp.data.datastore.core.mapping.Datastore 数据异常:无法将类 PageRequest 转换为 Datastore
【发布时间】:2020-05-08 17:22:27
【问题描述】:

我对 Spring 数据有疑问。当我将@Query注解与Pageable一起使用时,例如:

  @Query("SELECT * FROM myTable WHERE myTable.t_blob_name > NULL")
    Slice<MyTable> findAllWithPageable(Pageable pageable);

我将有下一个例外(该应用程序在谷歌云平台上运行):

org.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException: Unable to convert class org.springframework.data.domain.PageRequest to Datastore supported type.
at org.springframework.cloud.gcp.data.datastore.core.convert.DatastoreNativeTypes.wrapValue (DatastoreNativeTypes.java:166)
at org.springframework.cloud.gcp.data.datastore.core.convert.TwoStepsConversions.convertOnWriteSingle (TwoStepsConversions.java:320)
at org.springframework.cloud.gcp.data.datastore.repository.query.GqlDatastoreQuery.bindArgsToGqlQuery (GqlDatastoreQuery.java:233)
at org.springframework.cloud.gcp.data.datastore.repository.query.GqlDatastoreQuery.execute (GqlDatastoreQuery.java:118)
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)

这是一个谷歌云数据存储语法和主要问题 - 如何解决这个问题?

【问题讨论】:

    标签: spring google-cloud-datastore datastore gql


    【解决方案1】:

    有一个可在 GQL 中使用的受支持类列表。如果您愿意,您可以在 reference point 158.5.2code on GitHub 中找到它。实际上Pageable 类不在其中。

    我注意到您没有在查询中使用此参数,因此我建议您使用Slice&lt;MyTable&gt; findAllWithPageable() 类似的查询,您可以在here 中找到。

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-11-22
      • 2010-09-10
      • 1970-01-01
      • 2020-07-13
      • 2021-12-14
      • 1970-01-01
      相关资源
      最近更新 更多