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.  [ 1 post ] 
Author Message
 Post subject: Mapping Collections via a Lookup Table
PostPosted: Thu Sep 04, 2008 1:00 pm 
Newbie

Joined: Thu Sep 04, 2008 12:44 pm
Posts: 10
Hello,

I am a new nHibernate user and am trying to map a common pattern that I have in nHibernate and am wondering if anyone could provide any guidance. Essentially I have three tables:

Code:
CREATE Table Setting
AS
SettingId int not null,
DefaultValue nvarchar(max),
SettingKey nvarchar(50)

CREATE TABLE UserSetting
AS
UserId int not null,
SettingId int not null,
SettingValue nvarchar(max)


CREATE TABLE User
AS
UserId int not null,
...other columns excluded



What I would like is for this to map to an IDictionary<string,Setting> on User.

Setting is defined as

Code:
public class Setting
{
property string Value{get;set;}
property SettingDefinition{get;set;}
}

public class SettingDefinition
{
property string Key{get;set;}
property string DefaultValue{get;set;}

}


I've also tried to do a simillar mapping and have just a Dictionary<string,string> on the user (And I would ignore the default value for now).

The only way I've been able to do this is by creating a view and using that as the table in the mapping file. But this then requires me to write some triggers on the views to gets the data access to work right and to me seems counter productive.

Can anyone point me to some resources or have any suggestions or ideas. I'd appreciate it.

Thanks,
Josh


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.