-->
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: Extra Association mapped to member
PostPosted: Tue Apr 26, 2011 8:12 am 
Newbie

Joined: Thu Nov 05, 2009 11:36 am
Posts: 6
I've got this question that's been bugging me and my vast and unfathomable intellect just can't grasp it. The case: I want to make multiple one-to-many relationships to the same entity using the fluent nhibernate automapper and export schema.

I have:

Base Class:

Code:
public abstract class Post<T> : Entity, IVotable, IHierarchy<T>
{
    public virtual string Name
    {
        get; set;
    }

    public virtual string BodyText
    {
        get; set;
    }

    public virtual Member Author
    {
        get; set;
    }
}

and Inheriting Class:

Code:
[Serializable]
public class WallPost : Post<WallPost>
{
    public virtual Member Receiver
    {
        get; set;
    }
}

The 'Member' properties of WallPost is a foreign key relationship to this class:

Code:
public class Member : Entity
    {
        public Member()
        {
           WallPosts = new IList<WallPost>();
        }

public virtual IList<WallPost> WallPosts
        {
            get; set;
        }
}

I hope you're with me until now. When I run the exportschema of nhibernate I expect to get a table wallpost with 'author_id' and 'receiver_id' BUT I get author_id, receiver_id,member_id. Why did the Nhibernate framework add member_id, if it's for the collection of posts (IList) then how do you specify that the foregin key relationship it should use to populate is receiver, i.e. member.WallPosts will return all the wallposts of the receiver.

I hope i made sense, if you need anything else to answer the question let me know and I'll try to provide.

Thanks in advance

E


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.