Hibernate 多表关联查询简单实用方法
public class Department implements java.io.Serializable {
??? // Fields
??? private Integer deptno;
??? private String dname;
??? private String loc;
??? private Set employees = new HashSet(0);
.................
}
public class Employee implements Serializable {
??? // Fields
??? private Integer empno;
??? private Department department;
??? private String ename;
??? private String job;
??? private Integer mgr;
??? private Date hiredate;
??? private Double sal;
??? private Double comm;
??? private String pictureuri;
....................}
Criteria cri = getSession().createCriteria(Employee.class);
cri.createAlias("department", "dept").add(Restrictions.eq("dept.dname", emp.getDepartment().getDname()));