0

我在 GemFire 地区拥有数百万个对象。我不希望findAll()执行默认 SDR 查询以一次性检索数百万个对象。我试图弄清楚是否有一种方法可以覆盖默认的 findAll 查询并提供 LIMIT 参数来限制从 GemFire 区域检索到的对象数量。这是我想做的一个例子:

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 版本

4

2 回答 2

0

以下对我有用。尝试使用 Integer 而不是 String 作为 findAll 的参数

 @Query("SELECT * FROM /Customer LIMIT $1")
    List<Customer> findAll(@Param("limit") Integer max);
于 2014-09-16T15:20:38.223 回答
0

这个方便的使用 REST 访问 GemFire 数据的入门指南 ( https://spring.io/guides/gs/accessing-gemfire-data-rest/ ) 是不久前编写的,可能对您的特定用例有所帮助。

于 2014-03-17T04:50:47.580 回答