-->
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.  [ 3 posts ] 
Author Message
 Post subject: Newbe Question
PostPosted: Tue Feb 05, 2008 10:31 am 
Newbie

Joined: Sat Feb 02, 2008 10:17 pm
Posts: 2
First off as always thanks to NHibernate and the many active people who help support it. I am very new to NHibernate and have a simple mapping question that I hope you can help with.

Quick use case. I want to create invitations that contain one of the many possible invitation details. Essentially the invitation detail is configurable this I had to split it into two tables.

Very simple set up. Mind you this is Pseudo code.

class Invitation
{
Guid mId;
InvitationDetail mInvitationDetail;
}

class InvitationDetail
{
Guid mId;
string mSubject;
string mInvitationText;
}

//Sample Program

InvitationDetail detail = InvitationDetail.Create(selectedDetailId);
Invitation invite = new Invitation(detail);
invite.Invite();

So InvitationDetail is composed in my Invitation class. Thus Invitation has-a InvitationDetail. The data model is two tables. Invitation has the id of the specified invitationdetail to that was selected for use.


Tbl_Invitation
PK UID Id
UID InvitationDetailId

Tbl_Invitation_Detail
PK UID Id
VARCHAR Subject
VARCHAR InvitationText

My question is what mapping should I use. I do not think one-to-one is what I am looking at here as there key is not shared. Many-to-One seems a bit wrong as well. Is this just a simple component?

BDN


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 05, 2008 11:23 am 
Beginner
Beginner

Joined: Sun Nov 18, 2007 10:39 am
Posts: 46
Location: Liverpool, England
It sounds as though it should be a one to many, where invitation detail is the one, and invitation is the many? If I'm reading it right, invitation detail is some sort of template that multiple invitations will use?

Kev


Top
 Profile  
 
 Post subject: Thanks Kev
PostPosted: Tue Feb 05, 2008 11:41 am 
Newbie

Joined: Sat Feb 02, 2008 10:17 pm
Posts: 2
Thanks for the reply. I suppose your assertion is correct. Let me give it a try using that line of thinking.

Thanks,
BDN


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