2010-09-07 99 views
0

我有SQL查询,我不知道如何在休眠如何在休眠

select lp.lnprdtname,la.lid,la.step 
from mfic.lnapp as la 
left join mfic.lnprdt as lp on lp.lnprdtid in 
    (select lnprdtid from mfic.lnapp where lid in 
     (select lid from mfic.lnbrwr where brwrid in 
      (select brwrid from mfic.brwr where uid=1))) 
where la.lid in 
    (select lid from mfic.lnbrwr where brwrid in 
     (select brwrid from mfic.brwr where uid=1)); 

感谢写事先编写子查询

+0

此查询应该被重构,以使用连接。 – dotjoe 2010-09-07 16:29:28

回答

1

如这里说: Chapter 14. HQL: The Hibernate Query Language - 14.13. Subqueries

from DomesticCat as cat 
where cat.name not in (
    select name.nickName from Name as name 
) 

请注意,HQL子查询只能出现在select或where子句中。

无论如何,我不知道这是一个好主意,在一个单一的语句Concat的这么多的子查询...

+0

好的,谢谢,还有其他想法吗? – Ganesamoorthy 2010-09-07 16:36:10

+0

是的,我会尝试在数据库视图中编写这些子查询,并使Hibernate访问更加容易。 – 2010-09-07 16:51:38