【问题标题】:Override findAll() Spring Data Gemfire Repo Queries覆盖 findAll() Spring Data Gemfire Repo 查询
【发布时间】:2014-02-21 18:50:01
【问题描述】:

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

【问题讨论】:

    标签: spring-data spring-data-rest spring-data-gemfire


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      以下内容对我有用。尝试使用整数而不是字符串作为 findAll 的参数

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-01-31
        • 2020-08-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多