Hi Hudson - thanks for the reply.

After researching this more, I realize what I'm really trying to do
from a design perspective may have more to do with an 'optional
relationship' than relational inheritance. Ayende has a posting about
it as an NHib many-to-any mapping (http://ayende.com/Blog/archive/
2009/04/22/nhibernate-mapping-ltmany-to-anygt.aspx). There is also a
nice posting I found that approaches it as the 10% of cases where you
really do want a one-to-one relationship, and has an FNH solution
using an Alteration (http://whereslou.com/2010/01/03/extending-
nhibernate-data-with-one-to-optional-relationships). I found it as a
response to the one James Gregory wrote (http://blog.jagregory.com/
2009/01/27/i-think-you-mean-a-many-to-one-sir/) about the other 90% of
cases.

Is there an FNH officially sanctioned approach to mapping an optional
relationship fluently that you know of?

Cheers,
Berryl

On Jan 19, 5:24 am, Hudson Akridge <[email protected]> wrote:
> And of course, posting the .hbm.xml that gets exported :)
>
> On Tue, Jan 19, 2010 at 7:23 AM, Hudson Akridge 
> <[email protected]>wrote:
>
>
>
> > Would you mind doing a .ExportTo() on the config after you finish
> > automapping? It'll help us understand what Automapper is trying to do.
>
> > On Tue, Jan 19, 2010 at 12:13 AM, Berryl Hesh <[email protected]> wrote:
>
> >> Hello
>
> >> I am trying to map a hierarchy as table per class, and I'm getting the
> >> following exception:
>
> >> NHibernate: INSERT INTO ResourceBases DEFAULT VALUES; select
> >> last_insert_rowid()
> >> TestCase
>
> >> 'Smack.ConstructionAdmin.Tests.Data.MappingTests.ResourceMappingTests.CanSaveAndLoad_StaffMemberResource'
> >> failed: NHibernate.Exceptions.GenericADOException : could not insert:
> >> [Smack.ConstructionAdmin.Domain.Model.Resources.StaffMemberResource]
> >> [SQL: INSERT INTO ResourceBases DEFAULT VALUES; select
> >> last_insert_rowid()]
> >>  ----> System.Data.SQLite.SQLiteException : Abort due to constraint
> >> violation
> >> ResourceBases.ResourceType may not be NULL
>
> >> ResourceType is my Discriminator column as defined in the following
> >> mapping override:
>
> >>    public class ResourceBaseMap : IAutoMappingOverride<ResourceBase>
> >>    {
> >>        public void Override(AutoMapping<ResourceBase> m)
> >>        {
> >>            m.IgnoreProperty(x => x.Name);
> >>            m.IgnoreProperty(x => x.BusinessId);
> >>            m.IgnoreProperty(x => x.OrganizationName);
>
> >>            m.DiscriminateSubClassesOnColumn("ResourceType").Length
> >> (255);
>
> >>            m.HasMany(x => x.Allocations).AsSet();
> >>        }
> >>    }
>
> >>    public class StaffMemberResourceMap :
> >> IAutoMappingOverride<StaffMemberResource>
> >>    {
> >>        public void Override(AutoMapping<StaffMemberResource> m)
> >>        {
> >>            m.References(x => x.StaffMember);
> >>        }
> >>    }
>
> >> My understanding is that the value in the discriminator column will
> >> default to the full class name of the subclass, but SQLite seems to
> >> think it's getting a NULL value instead.
>
> >> Can someone please enlighten me as to how I'm abusing my mapping to
> >> get this error?
>
> >> Thanks,
> >> Berryl
>
> >> --
> >> 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]<fluent-nhibernate%[email protected]>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/fluent-nhibernate?hl=en.
>
> > --
> > - Hudson
> >http://www.bestguesstheory.com
> >http://twitter.com/HudsonAkridge
>
> --
> - Hudsonhttp://www.bestguesstheory.comhttp://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