-->
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: Proper way to map List<string>
PostPosted: Fri Mar 23, 2007 7:39 pm 
Pro
Pro

Joined: Fri Nov 19, 2004 5:52 pm
Posts: 232
Location: Chicago, IL
Hibernate version: 1.2.0.CR1

Mapped class excerpt:

private List<string> authorizedUsers = new List<string>();

public List<string> AuthorizedUsers
{
get { return authorizedUsers; }
set { authorizedUsers = value; }
}

Mapping document except:

<property name="AuthorizedUsers" length="65536"/>

Hi all,

I have a list of strings in a class that I'm persisting to the database using NHibernate. I'm wondering what the recommended way of doing this is? The way I have it setup now, as far as I know it's using binary serialization (presumably BinaryFormatter) to save it to a column in the database. It seems to work fine. The question I have isn't so much an NHibernate one, but, one about binary serialization in general. I'm wondering what will happen when I upgrade from .NET 2.0 to .NET 3.0. Is it going to throw a versioning exception when it tries to deserialize a List that was serialized using .NET 2.0 when I'm using .NET 3.0? In the past, I've avoided having lists of strings and instead created another class with a string field and and id.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2007 10:50 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
I'm using Hibernate, not NHibernate, so I'm not sure this concept also exists.
But could not you define a UserType to do this? Else, you could define a table to contain those Strings, mapped as a component I guess.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.