Well, everithing about cascades, and etc. is written and made to work just fine.
Actually the code fails in just one case - when I remove the person and then add a new unsaved transcient instance with THE SAME ID.
If I simply remove person, or add a persistent person or add a new unsaved trancient user with ID not stored in the DB everything is fine, fine, fine up to perfect.
The only problem arises when I remove a persistent object from the collection and later on add a new transcient instance with the same ID.
Hibernate checks the version number of the newly added object and finds the unsaved value - in my case negative. Then it tries to insert a new row. But on the previous removal the delete statement is missed because the group is detached and of course not savet - this is application transaction, wrigtht ?
|