Hi,

I have a very frustrating problem and I can't find a solution for it.

I have a class hierarchy like so:

abstract Entity -> abstract AudibleBlock
-> FixedBlock
-> abstract ConfigurableBlockBase<T>
---> DateBlock
---> PhoneNumberBlock

Entity is the base type of AudibleBlock, which is the base type of
FixedBlock and ConfigurableBlockBase<T> which is the base type of
DateBlock and PhoneNumberBlock.

I want table-per-subclass strategy and I want a table AudibleBlock.
Because of this, in my automapping configuration I
added .IncludeBase<AudibleBlock>().

FNH tries to create 4 tables:
1) AudibleBlock (works)
2) FixedBlock with PK AudibleBlockId (works)
3) DateBlock with PK ConfigurableBlockBase`1 (doesn't work)
4) PhoneNumberBlock with PK ConfigurableBlockBase`1 (doesn't work)

The last two classes have two problems:
1) The PK shouldn't use the class name of the direct base type,
because there exists no table for this base type and the PK is a FK to
the table AudibleBlock. It makes no sense to name the PK any other
than the PK of FixedBlock.
2) The name of the PK column is invalid. Note the backtick in the
name. This comes from the fact that ConfigurableBlockBase<T> is a
generic class.

I have found no way around this issue. I tried to use a specific
convention:
    public class ConfigurableBlockBaseSubclassConvenion :
IJoinedSubclassConvention,
                                   IJoinedSubclassConventionAcceptance
    {
        public void Apply(IJoinedSubclassInstance instance)
        {
            instance.Key.Column("AudibleBlockId");
        }

        public void
Accept(IAcceptanceCriteria<IJoinedSubclassInspector> criteria)
        {
            criteria.Expect(
                x =>
                x.EntityType.BaseType != null &&
x.EntityType.BaseType.IsGenericType
                && x.EntityType.BaseType.GetGenericTypeDefinition() ==
typeof(ConfigurableBlockBase<>));
        }
    }

But the call to Column is without effect, because the method returns
immediately as the mapping has user defined columns...

Am I missing something completely, or are this multiple bugs at play??

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to