I am trying to get data using hibernate. My query is correct but record for particular id does not exist it still returns one record (return list size is 1) with all null
values.
Below is part of code:
org.hibernate.SQLQuery query = getCurrentSession().createSQLQuery(sqlQuery);
List<?> resultList = query.list(); // resultList size is one having all null values but size should be zero
The sqlQuery
I am trying is below:
SELECT SUM(table1.column1=1) as column1,
SUM(table1.column2=1) as column2,
SUM(table1.column3=1) as column3
FROM table1
RIGHT JOIN table2
ON table1.unitid =table2.id
RIGHT JOIN groupsunits
ON table1.unitid =groupsunits.unitid
where table2.status = 'active' and groupsunits.group_id=415
Please share your suggestions for this issue.