ah... I forgot something... The reason is: *a horse is equal to a stone; both are just atoms*
On Tue, Apr 26, 2011 at 11:51 AM, Fabio Maulo <[email protected]> wrote: > Using NHibernateMystic with > private readonly Type[] baseTypesToRecognizeRootEntities = new[] {typeof > (AbstractEntity<>), typeof (Entity), typeof(Post<>)}; > > and this mapping > private void ConfOrmMapping(ObjectRelationalMapper orm, Mapper mapper) > { > } > yes! zero mappings line > > The schema result is: > CREATE TABLE [dbo].[Members]( > [Id] [int] NOT NULL, > PRIMARY KEY CLUSTERED > ( > [Id] ASC > )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] > ) ON [PRIMARY] > CREATE TABLE [dbo].[WallPosts]( > [Id] [int] NOT NULL, > [ReceiverId] [int] NULL, > [Name] [nvarchar](255) NULL, > [BodyText] [nvarchar](255) NULL, > [AuthorId] [int] NULL, > PRIMARY KEY CLUSTERED > ( > [Id] ASC > )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = > OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] > ) ON [PRIMARY] > ALTER TABLE [dbo].[WallPosts] WITH CHECK ADD CONSTRAINT > [FK8C31182D2C7AC916] FOREIGN KEY([AuthorId]) > REFERENCES [dbo].[Members] ([Id]) > ALTER TABLE [dbo].[WallPosts] CHECK CONSTRAINT [FK8C31182D2C7AC916] > ALTER TABLE [dbo].[WallPosts] WITH CHECK ADD CONSTRAINT > [FK8C31182DF745ED00] FOREIGN KEY([ReceiverId]) > REFERENCES [dbo].[Members] ([Id]) > ON DELETE CASCADE > ALTER TABLE [dbo].[WallPosts] CHECK CONSTRAINT [FK8C31182DF745ED00] > > And the result XML mapping is: > <class name="WallPost" table="WallPosts"> > <id name="Id" type="Int32"> > <generator class="hilo"> > <param name="max_lo">100</param> > </generator> > </id> > <many-to-one name="Receiver" column="ReceiverId" /> > <property name="Name" /> > <property name="BodyText" /> > <many-to-one name="Author" column="AuthorId" /> > </class> > <class name="Member" table="Members"> > <id name="Id" type="Int32"> > <generator class="hilo"> > <param name="max_lo">100</param> > </generator> > </id> > <bag name="WallPosts" inverse="true" cascade="all,delete-orphan"> > <key column="ReceiverId" on-delete="cascade" /> > <one-to-many class="WallPost" /> > </bag> > </class> > > On Tue, Apr 26, 2011 at 10:18 AM, oystagoymp <[email protected]> wrote: > >> 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: >> >> 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: >> >> [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: >> >> 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 >> >> P.s. If I change the property name from 'Receiver' to 'Member' i.e. >> public virtual Member Member, only two associations are made instead >> of 3, author_id and member_id. >> >> E >> >> -- >> You received this message because you are subscribed to the Google Groups >> "nhusers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/nhusers?hl=en. >> >> > > > -- > Fabio Maulo > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
