類的所有科目
DetachedCritiera subjects = DetachedCritiera.for(Class.class)
.add(Expression.eq("id", classId))
.createAlias("subjects", "subject")
.setProjection(Projections.Property("subject.Id"));
DetachedCritiera sectrionSubjects = DetachedCritiera.for(Class.class)
.add(Expression.eq("id", classId))
.createAlias("section", "section")
.createAlias("section.subjects", "subject")
.setProjection(Projections.Property("subject.Id"));
DetachedCritiera gradeSubjects = DetachedCritiera.for(Class.class)
.add(Expression.eq("id", classId))
.createAlias("grade", "grade")
.createAlias("grade.subjects", "subject")
.setProjection(Projections.Property("subject.Id"));
List<Subject> allSubjectsOfClass = session.createCriteria(Subject.class)
.add(new Disjunction()
.add(Subqueries.in("id", subjects))
.add(Subqueries.in("id", sectrionSubjects))
.add(Subqueries.in("id", gradeSubjects))
)
.list<Subject>();