-->
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.  [ 5 posts ] 
Author Message
 Post subject: mapping collection
PostPosted: Thu Jun 28, 2007 11:30 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Hello,

I would like to map collections using List<> type and not ISet<> type. Is it possible ? How ?

thanks,

mathmax


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 2:28 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/collections.html#collections-mapping

You seem to have mainly very basic questions. Have you read the documentation?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 4:10 pm 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Sorry, I just begin using nhibernate. I read the documentation, but it's a bit difficult to understand as I'm french. In the documentation, it is said :
Quote:
All collection types except ISet and bag have an index column - a column that maps to an array or IList index
or IDictionary key.

Does it mean I should add a column in my child table just to have the possiblity to use a List ? Why is this coumn necessary ?
Moreover, I cannot see <index-one-to-many> tag. Why ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 1:36 am 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
In general:

<set> maps to ISet
<bag> and <list> map to IList
<map> maps to IDictionary

Using <bag> will allow you to map to an IList without creating an index column. From the paragraph after the one you cite:

Quote:
A bag is an unordered, unindexed collection which may contain the same element multiple times. The
.NET collections framework lacks an IBag interface, hence you have to emulate it with an IList. NHibernate
lets you map properties of type IList or ICollection with the <bag> element. Note that bag semantics are not
really part of the ICollection contract and they actually conflict with the semantics of the IList contract
(however, you can sort the bag arbitrarily, discussed later in this chapter).


Also, I would definitely read section 15.5: http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/performance.html#performance-collections

Others may have suggestions about French language resources.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 6:21 am 
Regular
Regular

Joined: Tue Jun 26, 2007 11:50 am
Posts: 105
Thank you very much.
So I'll use a bag collection.
Could you help me on the other post ? http://forum.hibernate.org/viewtopic.php?t=976872


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