[英]Hibernate Criteria API result narrowing on foreign key
I'm using Hibernate Criteria API in my web project.我在我的 web 项目中使用 Hibernate Criteria API。 Currently I got stuck in a serious problem.
目前我陷入了一个严重的问题。 I've following scenario.
我有以下场景。
I want to get all students of a particular school (say with S_ID=1), but unable to do so.我想获得特定学校的所有学生(比如 S_ID=1),但无法这样做。 The problem is that I don't know what restriction to add to criteria.
问题是我不知道要向标准添加什么限制。
尝试:
session.createCriteria(Student.class).createAlias("your_class_property", "class").createAlias("class.your_school_property", "school").add(Restrictions.eq("school.id", 1)).list()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.