本文介绍了覆盖findAll()Spring Data Gemfire回购查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GemFire地区填充了数百万个对象.我不希望执行默认的findAll() SDR查询来一次获取数百万个对象.我试图找出是否有一种方法可以覆盖默认的findAll查询,并提供LIMIT参数来限制从GemFire区域中检索到的对象的数量.这是我想做的一个例子:

I have millions of objects populated in GemFire regions. I don't want default findAll() SDR query to be executed to retrieve the millions of objects in one shot. I am trying to figure out if there is a way to override the default findAll query and provide the LIMIT param to restrict the number of objects retrieved from GemFire Regions. Here is an example of what I want to do:

NoRepositoryBean
public interface CrudRepository<T, ID extends Serializable> extends Repository<T, ID> {

/**
 * Returns all instances of the type.
 *
 * @return all entities
 */
Iterable<T> findAll();
}


public interface MyRepository extends CrudRepository<MyRepoObject, String> {


@Query("SELECT * FROM MyRegion LIMIT $1")
Iterable<CellTower> findAll(@Param("limit") String limit);

}

当前,我使用的是Spring Data Gemfire 1.4.0.BUILD-SNAPSHOT和Spring Data REST 2.0.0.BUILD-SNAPSHOT版本

Currently, I am on Spring Data Gemfire 1.4.0.BUILD-SNAPSHOT and Spring Data REST 2.0.0.BUILD-SNAPSHOT version

推荐答案

以下内容对我有用.尝试使用Integer而不是String作为查找all

The following worked for me. Try using an Integer instead of a String as your parameter to findAll

 @Query("SELECT * FROM /Customer LIMIT $1")
    List<Customer> findAll(@Param("limit") Integer max);

这篇关于覆盖findAll()Spring Data Gemfire回购查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 23:39