That's what I said! =p (article title pending...)

On Thu, Jul 16, 2009 at 4:12 PM, James Gregory <[email protected]>wrote:

> I think you mean a many to one, 
> sir<http://blog.jagregory.com/2009/01/27/i-think-you-mean-a-many-to-one-sir/>
>  :)
>
> On Thu, Jul 16, 2009 at 9:56 PM, Hudson Akridge 
> <[email protected]>wrote:
>
>> What you may be looking to do here is use two one-to-many associations on
>>> both sides
>>
>>
>> Erm, that should read "two many-to-one associations" (.References() in
>> FNH), apologies for the confusion.
>>
>> On Thu, Jul 16, 2009 at 3:55 PM, Hudson Akridge <[email protected]
>> > wrote:
>>
>>> It's been a while since I've done one-to-one's, but I'll give this a try
>>> :)
>>> I believe you need to have a "constrained" setting for one of the sides
>>> to start with, this denotes which side and how the one-to-one saves.
>>>
>>> I'm actually not entirely sure that this mapping is legal for one-to-one,
>>> because as far as I'm aware, and have implemented in the past, the primary
>>> key's of both entities must be identical, and so you map the "child" id
>>> generation to be Foreign, and set it to the property of the one-to-one
>>> association. But with a subclass, by definition, they can't be, since they
>>> exist in the same table structure, and will collide ID's.
>>>
>>> What you may be looking to do here is use two one-to-many associations on
>>> both sides.
>>>
>>> I don't know what the design is you're shooting for, but one other red
>>> flag for me is two subclasses having essentially a single entity reference
>>> to the other. Typically this means those two classes can be merged, and you
>>> might just want to persist an enum that changes what type of Activity a user
>>> is dealing with.
>>>
>>> On Thu, Jul 16, 2009 at 3:30 PM, Berryl Hesh <[email protected]> wrote:
>>>
>>>>
>>>> Hello:
>>>>
>>>> I was expecting the HasOne relationship that is part of my inheritance
>>>> mapping to not let me save a ProjectActivity unless it's Project
>>>> attribute exists in the db (Project is a mapped Entity also). Is there
>>>> an option I can use to enforce this?
>>>>
>>>> Thanks!
>>>> B
>>>>
>>>> Domain inheritance hierarchy
>>>> -------------------------------------------------
>>>> public abstract class Activity : Entity    {      ...  }
>>>>
>>>> public class ProjectActivity : Activity    {
>>>>        public virtual Project Project { get; private set; }
>>>>  }
>>>>
>>>> public class AccountActivity : Activity    {
>>>>        public virtual Account Account{ get; private set; }
>>>>  }
>>>>
>>>> Mapping
>>>> -----------------------
>>>> public class ActivityMap : IAutoMappingOverride<Activity>
>>>>    {
>>>>        public void Override(AutoMap<Activity> mapping)
>>>>        {
>>>>           ..........
>>>>
>>>>            mapping.DiscriminateSubClassesOnColumn("ActivityType")
>>>>                .SubClass<ProjectActivity>("P",
>>>>                    x => x.HasOne(y => y.Project)
>>>>                        .Cascade.None()
>>>>                        .FetchType.Join())
>>>>
>>>>                .SubClass<AccountActivity>("A",
>>>>                    x => x.HasOne(y => y.Account).Cascade.SaveUpdate
>>>> ().FetchType.Join())
>>>>        }
>>>>    }
>>>>
>>>>
>>>
>>>
>>> --
>>> - Hudson
>>> http://www.bestguesstheory.com
>>> http://twitter.com/HudsonAkridge
>>>
>>
>>
>>
>> --
>> - Hudson
>> http://www.bestguesstheory.com
>> http://twitter.com/HudsonAkridge
>>
>>
>>
>
> >
>


-- 
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to