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: Mapping string or integer collections
PostPosted: Mon Dec 15, 2008 7:16 am 
Newbie

Joined: Mon Dec 15, 2008 6:59 am
Posts: 6
Hi all.

How can I map a string (or integer) collection with a one-to-many relationship?

For example, if I have a class like:

class Person {
...
public IList<string> NickNames {
...
}
}

and a table schema like the following:

table person {
ID int,
...
}

table nickNames {
ID int,
PersonID int,
nick varchar(255)
}

can I directly map NickNames Person's property? Or have I to wrap a nickname into a NickName class containing just one string property?

Thanks a lot,
Marcello.


Top
 Profile  
 
 Post subject: Re: Mapping string or integer collections
PostPosted: Mon Dec 15, 2008 9:50 am 
Newbie

Joined: Mon Dec 15, 2008 6:59 am
Posts: 6
Finally, I figured out how to map value types into collections.
The key is the <element> tag.
The mapping file looks like:

<set name="NickNames" table="NickNames" cascade="all-delete-orphan">
<key column="PersonID"/>
<element type="String" column="nick" not-null="true"/>
</set>

Thanks.
Marcello.


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.