Hi everybody,
If I load an object with its children in eager mode, example Person with its adresses,
I change my addresses collection, first it was a persistentSet then I put an HashSet.
I do that because I don't keep my Hibernate objects throw my different layers, I translate them into other entities but keeping same data. So when I come back to update them
So when I come back to update my Person entity (I want to update adresses too, I put a cascade All in my settings)
It updates person entity, then addresses but then it tries
Code:
update address
set idPerson = null
where idAddress = ?
however it updated addresses just before.
At this time my addresses collection is an HashSet because I rebuild my Person entity, it's not a PersistentSet like the person entity I had when I loaded it first.
I tried to debug Hibernate code and I saw Hibernate considers it's a relation to break because the collection has been changed.
How does hibernate is able to see this collection modification ? perhaps because it's not a persistentSet.
Note hat the relation is inversed (Person is reponsible of address persistence). If it's not inversed there is no problem.
If I keep the relation inversed but with the same persistentSet thad I have loaded before it works.
Does anybody can explain this problem ?
Thanks