Exception:rg.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException:无法将 class PageRequest 转换为 Datastore

Exception:rg.springframework.cloud.gcp.data.datastore.core.mapping.DatastoreDataException: Unable to convert class PageRequest to Datastore

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

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

我将有下一个异常(该应用程序在 Google 云平台上运行):

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 (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)

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

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

我注意到您没有在查询中使用此参数,因此我建议使用 Slice<MyTable> findAllWithPageable() 您可能会在 here 中找到的类似查询。

希望对您有所帮助!