Joined: Fri May 20, 2005 6:05 am Posts: 8
|
I have read the documentation..
I set cascade to "save-update,delete". A quick sample would be
public class A {
private long aId;
private Set bs;
public long getAId() {return aId;}
public void setAId(long aId){this.aId= aId;}
public set getBs() {return bs;}
public void setBs(Set bs){this.bs = bs;}
}
public class B {
private long bId;
private Set bs;
private long aId;
public long getBId() {return bId;}
public void setBId(long bId){this.bId = bId;}
public set getCs() {return cs;}
public void setCs(Set bs){this.bs = cs;}
public long getAId() {return aId;}
public void setAId(long aId){this.aId= aId;}
}
public class C {
private long cId;
private long bId;
public long getCId() {return cId;}
public void setCId(long cId){this.cId= cId;}
public long getBId() {return bId;}
public void setBId(long bId){this.bId = bId;}
}
if I do
A a = new A();
Set bs = new Set(); // yes I know Set is not right but for demo only
B b = new B();
bs.add(b);
Set cs = new Set();
C c = new C();
cs.add(c);
bs.setCs(cs);
a.setBs(bs);
session.saveOrUpdate(a);
the insert on b fails because b.aId does not get set.
I have tried to map to the id and put the Object A there and neither worked.
John
|
|