2011-08-24 74 views
1

我正在通过sql执行此操作,但是我想在hql中执行此操作,select(select count(*)...)中的语句不适用于hql,任何消化和优化将不胜感激将sql转换为hql

SELECT u.username,u.device_tocken,sr.count 
from users u, 
    (select count(*) as count ,ssr.recepient as res from survey_recipient ssr where  
    (ssr.is_read is false and ssr.recepient in ('abc','xyz'))group by ssr.recepient) sr 
where 
    (u.username = sr.res and u.device_tocken is not null) 

回答

1

Hibernate不支持clouse中的子查询。 我尝试了很多事情,并放弃了,当我发现这jira问题。

看到这里https://hibernate.onjira.com/browse/HHH-3356

但是,如果你必须使用子查询可以创建数据库视图和在SQL正常表使用它们。