假设您的表格是这样的:
@Entitypublic class Professor{ K id; List<Student> students;}@Entitypublic class Student{ K profid; List<Assignments> assignments;}@Entitypublic class Assignments{ K studentid;}
使用别名的简单示例:
Criteria criteria = currentSession.createCriteria(Professor.class, "professor"); criteria.createAlias("professor.students", "student"); criteria.createAlias("student.assigments", "assigment"); criteria.add(Restrictions.eqProperty("professor.id", "student.profid")); criteria.add(Restrictions.eqProperty("assigment.studentid", "student.profid")); criteria.add(Restrictions.eq("id", 2411));return criteria.list();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)