I have 2 table with foreign key constraint enabled. When I use hibernate sync. to generate the schema mapping file, it help me to add the following tag to ensure a list in parent table to access child record:
Quote:
<set inverse="true" name="CourseTemplateFrameSet">
<key column="id" />
<one-to-many class="CourseTemplateFrame" />
</set>
However, then in my code I load an instance of parent object, then save it. When I saving the object, it complaint about : "Illegal attempt to associate a collection with two open sessions"
The java code of load is:
Quote:
session = getInstance().openSession(con);
session.load(st, st.getId()); // st is parent
TOP.read(session); // child record
LEFT.read(session);
BUTTON.read(session);
session.flush();
session.disconnect();
The java code of save is:
Quote:
session = getInstance().openSession(con);
session.update(st);
TOP.save(session);
LEFT.save(session);
BUTTON.save(session);
session.flush();
session.disconnect();
I think the exception is cause by I am not suppose to save / load the child record outside hibernate if I have put the above tag, right? I guess it should have better exception message about this, rather than "Illegal attempt to associate a collection with two open sessions", right?[/quote]