Component ColumnPrefix is broken in 1.2.0.712 (for NH3)

74 views
Skip to first unread message

Brian Chavez

unread,
Jul 16, 2011, 5:11:58 PM7/16/11
to Fluent NHibernate
*bump*

Component( x => x.Property).ColumnPrefix("MyPrefix") is seriously
broken.

http://stackoverflow.com/questions/6287698/fluentnhibernate-component-columnprefix-not-being-applied

Also, I'm using the 1.2.0.712 binary directly from FNH website (not
NuGet).

Brian Chavez

unread,
Jul 18, 2011, 10:01:53 PM7/18/11
to Fluent NHibernate
CONFIRMED, now 2 people confirming this bug....

http://stackoverflow.com/questions/6287698/fluentnhibernate-component-columnprefix-not-being-applied/6727557

Thanks,
Brian

On Jul 16, 2:11 pm, Brian Chavez <bcha...@bitarmory.com> wrote:
> *bump*
>
> Component( x => x.Property).ColumnPrefix("MyPrefix") is seriously
> broken.
>
> http://stackoverflow.com/questions/6287698/fluentnhibernate-component...

Alexander I. Zaytsev

unread,
Jul 21, 2011, 4:26:18 AM7/21/11
to fluent-n...@googlegroups.com
For me it is not working to.

I have the PropertyConvention:

        class CustomColumnNameConvention : IPropertyConvention
        {
            public void Apply(IPropertyInstance instance)
            {
                instance.Column(instance.Name.ToUpper());
            }
        }

and I've following test down:

        [Test]
        public void ComponentPropertiesAssumeComponentColumnPrefixWithPropertyConvention()
        {
            var autoMapper = AutoMap.Source(source, addressCfg)
                .Conventions.Add<CustomColumnNameConvention>();

            new AutoMappingTester<Customer>(autoMapper)
                .Element("class/component[@name='WorkAddress']/property[@name='Number']/column").HasAttribute("name", "WorkAddress_NUMBER");
        }

Tests added into AutoPersistenceModelComponentTests

James Gregory

unread,
Jul 21, 2011, 10:29:38 AM7/21/11
to fluent-n...@googlegroups.com
Alexander, does that test fail? If so, I'll add it to the test suite.

Alexander I. Zaytsev

unread,
Jul 22, 2011, 12:02:19 AM7/22/11
to fluent-n...@googlegroups.com
Yes it is.

Brian Chavez

unread,
Jul 22, 2011, 5:24:23 AM7/22/11
to Fluent NHibernate
Actually, I think I've found *my* problem.

After investigating the unit tests in the source code; it appears
that, in my case, my conventions were being applied differently
between FNH v1.1 and FNH v1.2.

My ColumnPrefix() call in the my property component mapping somehow
conflicted with IPropertyConvention calls that made
instance.Column("someName") calls.

I think what happened is this:

1. My ComponentMap would get executed. No problem here.

2. My ClassMap would Component(x =>
class.Property).ColumnPrefix("FOO") from Step 1.

3. My IPropertyConvention class would call
(IPropertyInstance)instance.Column( instance.Name )

It looks like:
* in FNH 1.1, Step 3 is not destructive to the column prefix when
calling instance.Column("").
* in FNH 1.2, Step 3 is destructive to any ColumnPrefix() previously
set and over-writes the *entire* column name (including the prefix).

I cleaned up my conventions for FNH 1.2 using
IPropertyConventionAcceptance to be careful not to blindly call
instance.Column(instance.Name) [now that calls are destructive to
column prefixes].

-Brian

On Jul 21, 9:02 pm, "Alexander I. Zaytsev" <haz...@gmail.com> wrote:
> Yes it is.

Brian Chavez

unread,
Jul 22, 2011, 5:46:23 AM7/22/11
to Fluent NHibernate
Updated my answer on stackoverflow if anyone is interested:

http://stackoverflow.com/questions/6287698/fluentnhibernate-component-columnprefix-not-being-applied

Thanks,
Brian

James Gregory

unread,
Jul 22, 2011, 6:56:21 AM7/22/11
to fluent-n...@googlegroups.com
Ah, that makes sense (though is obviously a bug). Conventions shouldn't be descructive, but columns have always been a bit of a weird edge case. This kind of thing is on my list of things to sort out once and for all, but for the time being I can fix this one case.
Reply all
Reply to author
Forward
0 new messages