问题
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);
}
Currently, I am on Spring Data Gemfire 1.4.0.BUILD-SNAPSHOT and Spring Data REST 2.0.0.BUILD-SNAPSHOT version
回答1:
This handy getting started guide on Accessing GemFire Data with REST (https://spring.io/guides/gs/accessing-gemfire-data-rest/) was written not long ago and may help with your particular use case.
回答2:
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);
来源:https://stackoverflow.com/questions/21942773/override-findall-spring-data-gemfire-repo-queries