2012-03-17 64 views
0

我有一個在一個Parent and a Child之間休眠的一對多映射。在數據庫中,Child table有一個parentId和其他一些細節。 如何外部將它們加入標準或多列HQL中。多列HQL外連接

即,在parentIdgenderInd

Givern的我的代碼snipet下面,

Parent類,

private parentId; 

private Set<Child> childSet; 

Child類,

private Long childId; 

private Parent parent; 

private String name; 

private String genderInd; 

回答

7

你可以在HQL中使用with運算符。

select p from Parent p left join p.childSet as cs with cs.genderInd = 'your_code'

正如HQL Reference說,

你可能會提供額外的加入使用HQL與關鍵字條件。

from Cat as cat 
    left join cat.kittens as kitten 
     with kitten.bodyWeight > 10.0