Hi Guys,
I am facing an issue in implementing the below query with Hibernate
Criteria Query. Can you please help me in implementing the same?
The Query is:
SELECT outCountry.COUNTRY_ID, outCountry.COUNTRY_DESCRIPTION,
outCountry.COUNTRY_TENANT,
(SELECT COUNT(*) FROM POPULATION population, LOCALITY locality,
STATE state, COUNTRY inCountry
WHERE population.LOCALITY_ID = locality.LOCALITY_ID
AND locality.STATE_ID = state.STATE_ID
AND state.COUNTRY_ID = inCountry.COUNTRY_ID
AND inCountry.COUNTRY_ID = outCountry.COUNTRY_ID
AND population.POPULATION_GENDER = "MALE") as MALE_COUNT,
(SELECT COUNT(*) FROM POPULATION population, LOCALITY locality,
STATE state, COUNTRY inCountry
WHERE population.LOCALITY_ID = locality.LOCALITY_ID
AND locality.STATE_ID = state.STATE_ID
AND state.COUNTRY_ID = inCountry.COUNTRY_ID
AND inCountry.COUNTRY_ID = outCountry.COUNTRY_ID
AND population.POPULATION_GENDER = "FEMALE") as FEMALE_COUNT
FROM COUNTRY outCountry;
The DDL Script is attached along with this email.
I am able to implement this with Native Query, but my requirement is to do
this with CriteriaBuilder.
I was checking in Google and found out in few pages that sub select/nested
select with count is not possible with Criteria. But there was no concrete
reason why this is not possible. Could you please help me in this regard?
Any help is highly appreciated.
With regards
Sudipta Deb.
Show replies by date