首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Hibernate 多表联系关系查询简单实用方法

2012-10-09 
Hibernate 多表关联查询简单实用方法public class Department implements java.io.Serializable {??? // F

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()));

热点排行