-->
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: Collection of Strings
PostPosted: Thu Apr 20, 2006 11:56 am 
Beginner
Beginner

Joined: Fri May 13, 2005 11:48 am
Posts: 32
How can I persist a collection of simple strings or ints or any value type?

Code:
public class User
{
    Guid _id;
    public Guid Id { get { return this._id; } }

    IList _roles = new ArrayList();
    public IList Roles { get { return _roles; } }
}


Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" schema="dbo">
    <class name="Security.User,Security" table="Users">
        <id name="Id" type="Guid" >
            <generator class="guid" />
        </id>
        <set name="Roles" table="Users_Roles" lazy="true">
            <key column="UserId" />
            <composite-element class="string" >
                <property name="value" /> <!-- ??? -->
            </composite-element>
        </set>
    </class>


This may not be possible and I realize that. I also realize that this isn't the best modeling practice. I am just curious if it is possible.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 21, 2006 2:54 am 
Newbie

Joined: Fri Apr 21, 2006 2:39 am
Posts: 4
U can persist a collection of strings as follows

<list name="_roles" table="User_Roles" >
<key column="Id" />
<index column="Idx" />
<element type="string" column="value" />
</list>


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.