Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring data select top 100

How can I select the top 100 through Spring data CrudRepository? I want to do something like that by I get an error.

List<Person> findTop100();

I do not want to use queries, hibernate or anything else. I just want to do it through spring data the easy and fast way

like image 859
The Strong Programmer Avatar asked Jun 16 '26 15:06

The Strong Programmer


2 Answers

Add a postfix "By" but without criteria there would works.

List<Person> findTop100By();
like image 52
Chris Avatar answered Jun 18 '26 05:06

Chris


You can use

List<Person> findAllByOrderedBy{Abc}Desc

Where Abc is parameter on which sorting to be done.

like image 33
Amit Gujarathi Avatar answered Jun 18 '26 04:06

Amit Gujarathi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!