I guess your pojos like this:
public class Dept{
private int dno;
private String dname;
private Set Emps;
public Dept( int dno, String dname, Set Emps){
......
}
/** set /get*/
}
public class Emp{
private int eno;
private String ename;
private Dept dept;
public Emp( int eno, String ename, Dept dept){
......
}
/** set /get*/
}
hibernate version 3.1 spring version 2.0
user spring's hibernate
1. Dept dept = new Dept();
dept.setDno(dno);
.....
dept.save(dept)
2. DetachedCriteria detachedCriteria = DetachedCriteria
.forClass(Emp.class);
detachedCriteria.createCriteria("demp").add(Expression.eq("dno",new Integer(10)));
|