2011-10-26 102 views
0
select part.PaId,part.PaName,part.PaPartNumber,part.PaGroup from Part as part,(select 
PaId,PaGroup from Part where PaPartNumber='195-15-12750') as pa where pa.PaId=part.PaID 
or pa.PaGroup=part.PaGroup 

什麼是hql查詢上面的?HQL等效於此Sql查詢

用類和屬性名稱替換我所有的名字,但會發生錯誤!

HQL:

Select part.ID,part.Name,part.PartNumber From Part as part,(Select par.ID,par.Group 
From Part as par Where par.PartNumber Like ?) as pa Where part.ID=pa.ID or 
part.Group=pa.Group 

錯誤:

SEVERE: line 1:73: unexpected token: (
Oct 26, 2011 7:23:01 PM org.hibernate.hql.ast.ErrorCounter reportError 
SEVERE: line 1:98: unexpected token: From 
unexpected token: (near line 1, column 73 [Select part.ID,part.Name,part.PartNumber 
From Depot.Entity.Part as part,(Select par.ID,par.Group From Depot.Entity.Part as par 
Where par.PartNumber Like ?) as pa Where part.ID=pa.ID or part.Group=pa.Group] 
[Ljava.lang.StackTraceElement;@1195c2b 
+0

沒有映射我們怎麼知道這個名字? – ssedano

回答

0

你只需要與Java屬性名和表名與Java類替換列名名稱,然後HQL準備就緒。