-->
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.  [ 2 posts ] 
Author Message
 Post subject: Calling iterator() "updates" the contained objects
PostPosted: Thu Feb 05, 2009 8:58 am 
Newbie

Joined: Thu Dec 11, 2008 5:13 am
Posts: 4
Hibernate version: 3

Hello,

Here is the problem I'm having:
- A have an object A that contains a list of objects B.
- Object B has a date field which is defined in the mapping xml like so:
Code:
<timestamp name="lastUpdate" column="last_update"/>

- If I retrieve object A through hibernate, and then browse its objects B by calling a.getBs().iterator(), update another field of object A and finally save A, hibernate will update the last_update field of all the related object B!

I do not want that! Why does Hibernate update this field when all I did was browse through the B objects without updating them? Actually the simple call to iterator() will cause this.

Hope anyone can help...
Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 05, 2009 7:09 pm 
Regular
Regular

Joined: Fri Jan 30, 2009 10:10 am
Posts: 74
Location: London
I suspect that Hibernate is replacing the Object B objects.

You could probably see for yourself what is going on behind the scenes by enabling SQL logging and checking whether there are delete and insert statements, or updates.


--
Stephen Souness


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

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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.