-->
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.  [ 10 posts ] 
Author Message
 Post subject: doesn't handle collections inside collections?
PostPosted: Tue Jul 20, 2004 8:15 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
Hi All, I have been having problems with nested collections. I have just found this comment on the web 'Unfortunately hibernate doesn't handle collections inside collections' at http://www.xwiki.org/xwiki/bin/view/Dev/UnorganisedFeedback

Is this true, that you cannot use collections inside collections?

Thanks

Paul :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 8:41 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Thats correct. It's not very good OO anyways.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:09 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
Hi Michael, thanks for the quick reply. I'm interested in why you think that it is not good OO? For example I have an Account object which contains multiple AddressBook objects & a user can add as many as they wish. These AddressBook objects need to contain multiple Contact objects which contain the info about each contact. How else would one model this?

Paul


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:21 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Code:
class Account {
   List<AddressBook> a
}

class AddressBook {
   List<Contact> b
}

class Contact {
   String name
}


Exactly as you described it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:37 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
But then surely I have a collection of Contact objects inside a collection of AddressBook objects inside an Account object, which is a collection inside of a collection which Hibernate cannot cope with & which you said was not very good OO? And is the problem I have been struggling with since attempting to port my app from CMP Entity Beans to Hibernate.

Paul :-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
This is not what a "nested collection" is. A nested collection would be this:

Code:
List<List>


Hibernate can perfectly handle the example i posted.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:58 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
OK. Thanks. It's me then :-) I've been having a real nightmare, with which should be my primary & which should be my inverse mapping & how I manage adding & removing things. I had a really odd experience, where in my junit test I add an AddressBook to the Account, then get the collection of AddressBooks from the Account, get my AddressBook object back from the collection & then call myCollection.contains(myAddressBook) & it returns false!!! Even though I just obtained the object from the same collection! I'll have to soldier on & try to figure it out.

Thanks Michael :-)
Paul


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 10:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
check your equals/hashCode implementation, thats the bug most likely. look here http://www.hibernate.org/109.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 10:23 am 
Regular
Regular

Joined: Fri Jul 16, 2004 3:04 pm
Posts: 52
Location: Wiltshire UK
Thanks Michael, I'll check that out, as my equals & hashcode at the moment do use the id!

Paul :-)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 06, 2008 1:01 pm 
Newbie

Joined: Mon Sep 22, 2008 9:31 am
Posts: 9
Does Hibernate still have the nested collection limitation in its latest versions of Hibernate that was indicated in this 2004 posting?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.