Hi Max,
Thanks, that was very helpful!
The only thing that makes me wonder is that in this
relation cat --->* Kitten the DB relation is done by having the cat PK
set as a foreign key in the Kitten table.
When I do: cat2.getKittens().add(kitten);
I assume that either an update to the FK in Kitten table will be done (when flushed)
or that the old record (with the previous parent) will be removed and a new record (with the current parent) will be added.
Which one of the above (if any) Hibernate will actually do?
Also, what will kitten.setParent(cat2) do to the DB in that case?
After all the above action was sufficient to maintain the relation
from the DB perspective.
If the latter action is not going to trigger any further DB updates can
I assume that if I load the same Kitten in a separate Session that the kitten
will have its relation to its parent set correctly (without having to
explicitly set it in the previous session)?
I think those questions cover that topic for me and I hope
you are OK with me asking so much...
Thank you very much,
Arie.
|