Nick Russler
Nick Russler

Reputation: 4704

JPA (Hibernate, Mysql) Get Count while setmaxresults is used

Hi in mysql theres a way to get the total count after selecting with LIMIT, simply selecting FOUND_ROWS. Is there a way to do that in jpa to ?

I use JPA with Hibernate as Persistence Provider and MySQL as underlying db.

It would be ok if the solution would not be "pure" jpa or even hibernate.

Upvotes: 1

Views: 792

Answers (1)

Mikko Maunu
Mikko Maunu

Reputation: 42114

No, there is not such a construct in JPA and also not out of the box in Hibernate.

Straight forward solution is of course to get total count with separate query. If that is not an option, then one possibility is to create interceptor as described here.

Upvotes: 2

Related Questions