How to get total result count from entity manager query

Viewed 241

I am working on pagination using spring boot. I am trying get total count of results from entity manager query for the pagination. For that I am getting maxresults to show from query, but how can i get total count of results.Please tell me i am new to enity manager.

    @Override
public List<User> getsearchresults(String result) {

    String query = "FROM User WHERE (education = :education) OR (city = :city)";

    return em
                .createQuery(query,User.class)
                .setParameter("education",education)
                .setParameter("city",city)
                .setMaxResults(5)
                .getResultList();
 }

this is how i write query which returns results but i need total number of result count.How can i do that plesase help me.

0 Answers
Related