:-) thanks James

On Thu, Aug 20, 2009 at 8:20 AM, James Gregory <[email protected]>wrote:

> I think we can probably get a change in. Might have to be a bit more clever
> than just looking at Type.BaseType though :)
>
>
> On Thu, Aug 20, 2009 at 1:07 PM, Everett Muniz <[email protected]>wrote:
>
>> Thanks for the feedback James.  I figured the issue was was the
>> inheritance layers I just wasn't sure whether it was by design or not.  Is
>> the best course to stick with the old-style deprecated approach or do you
>> think a change is likely?  I'd be willing to try to code the change if that
>> would be any help.
>>
>>
>> On Thu, Aug 20, 2009 at 3:38 AM, James Gregory 
>> <[email protected]>wrote:
>>
>>> It's probably got something todo with the layers between, I'm pretty sure
>>> the SubclassMap only checks for direct parents when associating classes.
>>>
>>>
>>> On Thu, Aug 20, 2009 at 2:50 AM, Everett Muniz 
>>> <[email protected]>wrote:
>>>
>>>> Using a pretty current PRE-RC1 set of binaries the follow works
>>>> brilliantly...
>>>>    public class ColorSourceMapping : ClassMap<ColorSource>
>>>>     {
>>>>         public ColorSourceMapping()
>>>>         {
>>>>             Table("ColorSource");
>>>>             Id(typeof(Guid), "ID");
>>>>             JoinedSubClass<ConstantColorSource>("ID", s =>
>>>>             {
>>>>                 s.Map(x => x.Alpha);
>>>>                 s.Map(x => x.Blue);
>>>>                 s.Map(x => x.Green);
>>>>                 s.Map(x => x.Red);
>>>>             });
>>>>             JoinedSubClass<SubstringColorSource>("ID", s =>
>>>>             {
>>>>                 s.Map(x => x.Length);
>>>>                 s.Map(x => x.Start);
>>>>                 s.References(x => x.RecordAccessor)
>>>>                     .Column("RecordAccessorID")
>>>>                     .Cascade.All();
>>>>                 s.References(x => x.ColorMap)
>>>>                     .Column("ColorMapID");
>>>>             });
>>>>         }
>>>>     }
>>>>
>>>> ConstantColorSource is a direct subclass of ColorSource
>>>> (ColorSource->ConstantColorSource).  However, there are a few subclasses
>>>> between SubstringColorSource and ColorSource (ColorSource
>>>> ->..->..->SubstringColorSource).  Here's how I tried to convert this to the
>>>> subclass approach...
>>>>
>>>>     public class SubstringColorSourceMapping :
>>>> FluentNHibernate.Mapping.SubclassMap<SubstringColorSource>
>>>>     {
>>>>         public SubstringColorSourceMapping()
>>>>         {
>>>>             KeyColumn("ID");
>>>>             Map(x => x.Length);
>>>>             Map(x => x.Start);
>>>>             References(x => x.RecordAccessor)
>>>>               .Column("RecordAccessorID")
>>>>               .Cascade.All();
>>>>             References(x => x.ColorMap)
>>>>                 .Column("ColorMapID");
>>>>         }
>>>>     }
>>>>
>>>>     public class ConstantColorSourceMapping :
>>>> FluentNHibernate.Mapping.SubclassMap<ConstantColorSource>
>>>>     {
>>>>         public ConstantColorSourceMapping()
>>>>         {
>>>>             KeyColumn("ID");
>>>>             Map(x => x.Alpha);
>>>>             Map(x => x.Blue);
>>>>             Map(x => x.Green);
>>>>             Map(x => x.Red);
>>>>         }
>>>>     }
>>>>
>>>>     public class ColorSourceMapping : ClassMap<ColorSource>
>>>>     {
>>>>         public ColorSourceMapping()
>>>>         {
>>>>             Table("ColorSource");
>>>>             Id(typeof(Guid), "ID");
>>>>         }
>>>>     }
>>>>
>>>> The mapping file generated by the 3 classes above looks like this...
>>>>
>>>> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
>>>> default-access="property" auto-import="true" default-cascade="none"
>>>> default-lazy="true">
>>>>   <class xmlns="urn:nhibernate-mapping-2.2"
>>>> name="GBS.VersiLabel.Core.Domain.Model.ColorSource, GBS.VersiLabel.Core,
>>>> Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" table="ColorSource">
>>>>     <id type="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral,
>>>> PublicKeyToken=b77a5c561934e089">
>>>>       <column name="ID" />
>>>>       <generator class="guid.comb" />
>>>>     </id>
>>>>     <joined-subclass
>>>> name="GBS.VersiLabel.Core.Domain.Model.ConstantColorSource,
>>>> GBS.VersiLabel.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
>>>> table="`ConstantColorSource`">
>>>>       <key>
>>>>         <column name="ID" />
>>>>       </key>
>>>>       <property name="Alpha" type="System.Int32, mscorlib,
>>>> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>>>         <column name="Alpha" />
>>>>       </property>
>>>>       <property name="Blue" type="System.Int32, mscorlib,
>>>> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>>>         <column name="Blue" />
>>>>       </property>
>>>>       <property name="Green" type="System.Int32, mscorlib,
>>>> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>>>         <column name="Green" />
>>>>       </property>
>>>>       <property name="Red" type="System.Int32, mscorlib,
>>>> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>>>         <column name="Red" />
>>>>       </property>
>>>>     </joined-subclass>
>>>>   </class>
>>>> </hibernate-mapping>
>>>>
>>>>  You'll notice that the mapping has the ConstantColorSource but not
>>>> SubstringColorSource.
>>>>
>>>> I checked the wiki but it didn't seem to address the specific issue of
>>>> multi-level inheritance.
>>>>
>>>> Am I doing something wrong?
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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