[英]Hibernate criteria filter on foreign keys
Can we create deep alias for foreign key table using criteria? 我们可以使用条件为外键表创建深度别名吗? For example if I have three table
A
, B
and C
where C
is foreign key table of B
and B
is foreign key table of A
. 例如,如果我有三个表
A
, B
和C
,其中C
是B
外键表,而B
是A
外键表。
I want to apply filter like the following statement: 我想像下面的语句一样应用过滤器:
session.createCriteria(A.class).createAlias("A.bObjectField", "alias1")
.createAlias("alias1.cObjectField", "alias2")
.add(Restrictions.eq("alias2.id", 1));
Can I filter the table C
from A
using criteria? 我可以使用条件从
A
过滤表C
吗?
Thanks in advance. 提前致谢。
是的,只要您在映射中对外键建模,就没有问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.