I want to get the count of the results of a dynamically-generated HQL query, without actually getting the list of results. Say that the query I have is something like:
This should do the trick:
select count(*) FROM Company c JOIN ...
There is no sub-select involved, just instead of returning Company
, you return the count.
Edit: The FETCH
is out of place now. You're not returning the entities from the query, but only the count, thus, Hibernate complains. Removing it should help:
select count(product) from org.myCompany.applicant.entity.Applicant applicant
LEFT OUTER JOIN applicant.products product