-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate tries to delete oneToMany if not PersistentSet
PostPosted: Sun Jul 18, 2010 5:26 am 
Newbie

Joined: Wed Jul 14, 2010 3:10 am
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.