-->
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: Questionable collection behavior
PostPosted: Thu May 12, 2005 9:14 am 
Newbie

Joined: Thu May 12, 2005 8:47 am
Posts: 1
I'm not really sure if this behavior is a problem or not, but it does seem questionable to me. I've checked forums and docs, but have not found an adequate explanation as to why it is behaving this way. So, if anyone can shed some light - I would greatly appreciate it.

class Trust {
public Set getTrustees();
public void setTrustees(Set trustees);
}

Assuming the above class, doing the following (psuedo-code) fails:

Trust trust = Hibernate.find(key);
trust.setTrustees(new Set());
Hibernate.save(trust);
Trust found = Hibernate.find(key);
assertTrue(trust.getTrustees().size()==found.getTrustees().size());

However, this works:
Trust trust = Hibernate.find(key);
trust.getTrustees().clear();
Hibernate.save(trust);
Trust found = Hibernate.find(key);
assertTrue(trust.getTrustees().size()==found.getTrustees().size());


I understand that the collections in objects retrieved from Hibernate specialized Hibernate collections, but this still seems faulty to me, as the first case is a valid representation of the object's state we want saved, but it seems to be ignoring it.

If anyone can provide an explanation as to why this is happening - whether it be configuration on my part, architectural decision, or an actual defect, I would greatly appreciate it.

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