多列上的HQL外连接

0 hibernate join hql

我在hibernate之间有一对多的映射Parent and a Child.在数据库中,Child tableparentId一些其他细节.我怎样才能将它们连接到多个列的条件或HQL中.

即,在parentIdgenderInd等.

Givern低于我的代码,

Parent课堂上,

private parentId;

private Set<Child> childSet;
Run Code Online (Sandbox Code Playgroud)

Child课堂上,

private Long childId;

private Parent parent;

private String name;

private String genderInd;
Run Code Online (Sandbox Code Playgroud)

Man*_*uPK 7

您可以with在HQL中使用运算符.

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

正如HQL参考中所述,

您可以使用带有关键字的HQL提供额外的连接条件.

from Cat as cat
    left join cat.kittens as kitten
        with kitten.bodyWeight > 10.0
Run Code Online (Sandbox Code Playgroud)