-->
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: Bug in PersistentSet?
PostPosted: Wed Jan 18, 2006 12:48 pm 
Newbie

Joined: Sat Sep 24, 2005 12:24 pm
Posts: 7
Hi,

Hibernate version:3.0.5

I found that if I save an object with a unidirectonal toMany association I cannot remove an object from the association after save.
Here my dummy testcase:
Code:
User user = new User("test");
History h = new History();
user.addHistory(h);

dao.save(user);
user = dao.load("test");
assertTrue(1, user.getHistory().size());
//failed--->
assertTrue(user.removeHistory(user.getHistory().iterator.next()));


When I call Session.clear(); before dao.load(); it works.

I use a HashSet for the assoc. but after save the HashSet will be converted to a PersistentSet.
After debugging a see a comment in the class:
Code:
public PersistentSet(SessionImplementor session, java.util.Set set) {
      super(session);
      // Sets can be just a view of a part of another collection.
      // do we need to copy it to be sure it won't be changing
      // underneath us?
      // ie. this.set.addAll(set);
      this.set = set;
      setInitialized();
      setDirectlyAccessible(true);
   }



Can anyone help?
Juergen


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.