我在hibernate之间有一对多的映射Parent and a Child
.在数据库中,Child table
有parentId
一些其他细节.我怎样才能将它们连接到多个列的条件或HQL中.
即,在parentId
和genderInd
等.
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)
您可以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)
归档时间: |
|
查看次数: |
4116 次 |
最近记录: |