anthony wrote:
save parent first, it will hit the sequence to fill the id, then do what you want with children
Yup, that's what I'm doing, but in my value object for the table I have a Set with my children inside it. So when I save it complains. Do you mean to say save the parent with a NULL Set first and then go back and add it? I thought cascade set to "all" is supposed to handle this for me transitively?
Also, when I turn show_sql on, I see the SELECT for the sequence followed by the two inserts for the parent and child table sequentially. Shouldn't Hibernate now know the value for the PK per that SELECT?
TIA,
Lou
Save code as follows:
Code:
protected Serializable save(Object obj) throws DaoException {
Session s = null;
Monitor mon = MonitorFactory.start(this.getClass().getName() + ":save");
try {
s = getSession();
Serializable rtn = s.save(obj);
s.flush();
return rtn;
} catch (HibernateException e) {
throw new DaoException(e);
} finally {
closeSession(s);
mon.stop();
}
}