I am working with Hibernate 2.1.6 in a Swing GUI.
Class B has a field of type A.
Detached object a of class A is referenced by the GUI. I do a query (by HQL or load-by-ID) that loads b of class B from the database. Logically, b should point to a, but Hibernate doesn't know that, so when it loads b, and I navigate the reference, a "copy of" a is created and loaded as well.
But I need b to be hooked up to a. How do I do I make Hibernate recognize that the reference should point to the already-loaded (detached) object?
Do I lock() a at the beginning of the Session? That could be hard to do if, instead of just the one a, I have hundreds of detached objects of type A referenced by the GUI and I don't know which one needs to be lock-ed.
|