2011-03-22 74 views
0

如何寫這個的HQL查詢:HQL左的連接,其中左邊是空

select pp.* 
from Part pp 
left join Product p on pp.ProductID = p.ID 
where p.ID is null 

我需要無產品部分。部分有產權產品(多到一個)

我試圖

from Part p 
where p.Product is null 

但它產生無效的查詢。

感謝

回答

2

解決了與:

from Part p 
where not exists (from Product pr where p.Product = pr) 

更新: 而這正是因爲在SQL!

from Part p 
    left join p.Product as pr 
where pr is null 
0
from Part p 
where p.Product.Id is null 

應該工作 雖然你的查詢還應該工作。生成的查詢是什麼?