Hibernate-获取一条记录将从数据库中获取所有空值

时间:2015-08-19 08:23:37

标签: hibernate hibernate-criteria

我正在尝试使用hibernate获取数据。我的查询是正确的但是特定id的记录不存在它仍然返回一个记录(返回列表大小为1),其中包含所有null值。

以下是代码的一部分:

org.hibernate.SQLQuery query = getCurrentSession().createSQLQuery(sqlQuery);
List<?> resultList = query.list();  // resultList size is one having all null values but size should be zero

我正在尝试的sqlQuery如下:

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

请分享您对此问题的建议。

0 个答案:

没有答案
相关问题