lsp4jakarta icon indicating copy to clipboard operation
lsp4jakarta copied to clipboard

JEE11_Data: Repository methods returning Page or CursoredPage must declare a PageRequest parameter.

Open archana-1924 opened this issue 1 month ago • 0 comments

Description:

A PageRequest parameter must be declared in the repository method signature when:

  • The method returns a Page<E> (offset‑based pagination).
  • The method returns a CursoredPage<E> (cursor‑based pagination).

Without a PageRequest parameter, the method signature is invalid because the pagination context cannot be determined.

Examples:

Invalid example

public interface ProductRepository extends DataRepository<Product, Long> { 
    Page<Product> findByCategory(String category);  
    //Invalid: returns Page<Product> but no PageRequest parameter 
} 

Valid example

public interface ProductRepository extends DataRepository<Product, Long> { 
    Page<Product> findByCategory(String category, PageRequest pageRequest);  
    //Returns Page<Product>, PageRequest declared 
} 

Specification: 

https://jakarta.ee/specifications/data/1.0/jakarta-data-1.0#:~:text=A%20parameter%20of%20this%20type%20must%20be%20declared%20when%20the%20repository%20method%20returns%20a%20Page%20of%20results%2C%20as%20specified%20below%20in%20Offset%2Dbased%20Pagination%2C%20or%20a%20CursoredPage%2C%20as%20specified%20in%20Cursor%2Dbased%20Pagination.

Type of language feature proposed:

Select all that apply

  • [x] diagnostic
  • [ ] quick-fix
  • [ ] snippet
  • [ ] other, please specify:

archana-1924 avatar Nov 21 '25 04:11 archana-1924