Spring Data JPA - finding number of rows from the database
10,640
There is method count()
in CrudRepository
. You can check oficial documentation.
Related videos on Youtube
Author by
Matt-pow
Updated on June 04, 2022Comments
-
Matt-pow almost 2 years
I am a noob in Spring framework. I know there is the findAll method to query all the data in a database. Is there a way to count the number of rows in a database using the Spring framework and doesn't require to write a SQL query?
-
aswzen over 3 yearshow to add condition to that count
-
Woodchuck over 2 yearsYou could just add something like this to your repository: long countBySomeField(String someField);