Interlated
Interlated

Reputation: 5926

How to get PageRequest to work in spring boot with annotated query

I'm upgrading from spring boot 1 to spring boot 2.

I'm trying to pick off the first result only.

PageRequest pageRequest = PageRequest.of(0, batchSize, Sort.Direction.ASC, "id");

With an annotated query on the repository

@Query("select c from Component")
List<Component> findReturnComponent(PageRequest pageRequest);

I'm getting this error message

but parameter 'Optional[pageRequest]' not found in annotated query 'select c from Component

Upvotes: 0

Views: 3522

Answers (1)

Anisuzzaman Babla
Anisuzzaman Babla

Reputation: 7480

Use Pageable Interface instead of PageRequest

Pageable pageable = PageRequest.of(0, batchSize, Sort.Direction.ASC, "id");

and

@Query("select c from Component")
List<Component> findReturnComponent(Pageable pageable);

Upvotes: 6

Related Questions