Conventions not working with FNH 1.2?

55 views
Skip to first unread message

dwlodarczyk

unread,
Apr 9, 2011, 9:03:00 AM4/9/11
to Fluent NHibernate
After upgrade to newest version Conventions stop working?

For example i have:

public class TableNamingConvention : IClassConvention
{
public void Accept(IAcceptanceCriteria<IClassInspector>
criteria)
{
criteria.Expect(x => x.TableName, Is.Not.Set);
}

public void Apply(IClassInstance target)
{
target.Table(target.EntityType.Name + "Table");
}
}

and then:

Configuration fluentConfig = Fluently.Configure()
.ProxyFactoryFactory<NHibernate.ByteCode.Castle.ProxyFactoryFactory>()
.Database(MsSqlConfiguration.MsSql2000
.ConnectionString(c =>
c.Is(DatabaseConfiguration.ConnectionString))
.DefaultSchema(DatabaseConfiguration.Database +
".dbo")
.IsolationLevel("ReadCommitted")
.UseReflectionOptimizer()
.Mappings(m => m
.FluentMappings.AddFromAssemblyOf<CrmMap>()
.Conventions.AddFromAssemblyOf<TableNamingConvention>())
.BuildConfiguration();

and tables in generated mapping have no "Table" suffix. Before
changing to 1.2 it works like a charm.

Vahid

unread,
May 4, 2011, 3:51:41 AM5/4/11
to Fluent NHibernate
Hi,
To be specific, I am using FHN 1.2.0.705.
You can find it here:
http://teamcity.codebetter.com/viewType.html?buildTypeId=bt295&tab=buildTypeStatusDiv

After that, I have:

using System.Data.Entity.Design.PluralizationServices;
using System.Globalization;
using FluentNHibernate.Conventions;
using FluentNHibernate.Conventions.Instances;

namespace NHibernate.Helper.MappingConventions
{
public class TableNameConvention : IClassConvention
{
/*PluralizationService needs a ref. to
System.Data.Entity.Design.dll, v4.0.30319*/
PluralizationService _service =
PluralizationService.CreateService(CultureInfo.GetCultureInfo("en"));
public void Apply(IClassInstance instance)
{

instance.Table(_service.Pluralize(instance.EntityType.Name));
}
}
}
+

private Action<IConventionFinder> getConventions()
{
return c =>
{
c.Add<TableNameConvention>();
/*+ the other ones*/
};
}
+
var mappings = new AutoPersistenceModel()
.Where(....)
.Conventions.Setup(getConventions()) // <----
inject it here
.AddEntityAssembly(...)
.UseOverridesFromAssembly(...);

And it works for me.

James Gregory

unread,
May 12, 2011, 3:45:55 PM5/12/11
to fluent-n...@googlegroups.com
I've tried to reproduce both of your issues and I can't. I modified the Example.FirstProject and Example.FirstAutomappedProject example projects which are included with the FNH source, and both of them applied table naming conventions correctly.

@dwlodarczyk What version of FNH are you using exactly? You say 1.2, was that the official release or one of the pre-release builds? What's the build version?

@Vahid Try upgrading to the 1.2 official release, the version you're running is a few builds behind. I'm having no issues with the latest.

cremor

unread,
May 17, 2011, 1:23:19 AM5/17/11
to Fluent NHibernate
I have noticed something similar: Usually my conventions work like
before 1.2, but if I call ExportTo() in my fluent configuration, no
conventions are applied.

I can reproduce it by adding
".Conventions.Add(DefaultAccess.Property()).ExportTo("D:\\")" to
Examples.FirstProject of the current 1.x branch. The exported mappings
still contain the access strategies which are choosen by Fluent
NHibernate itself (backfield for Id, nothing specified for other
properties).

On May 12, 9:45 pm, James Gregory <jagregory....@gmail.com> wrote:
> I've tried to reproduce both of your issues and I can't. I modified the
> Example.FirstProject and Example.FirstAutomappedProject example projects
> which are included with the FNH source, and both of them applied table
> naming conventions correctly.
>
> *@dwlodarczyk* What version of FNH are you using exactly? You say 1.2, was
> that the official release or one of the pre-release builds? What's the build
> version?
>
> *@Vahid* Try upgrading to the 1.2 official release, the version you're

James Gregory

unread,
May 17, 2011, 4:10:06 AM5/17/11
to fluent-n...@googlegroups.com
Ah! I'll try it using ExportTo. I seem to remember having an issue like this a long time ago, perhaps we've regressed somehow. Thanks for the extra info.

Joseph Vano

unread,
Jun 2, 2011, 11:12:36 AM6/2/11
to fluent-n...@googlegroups.com
Ah, I ran into this as well with 1.2.0.712

Conventions are ignored if "ExportTo" is called.

Kevin

unread,
Jun 13, 2011, 9:31:55 AM6/13/11
to Fluent NHibernate
I can also confirm this to be the case.

On May 17, 1:23 am, cremor <cre...@gmx.net> wrote:
> I have noticed something similar: Usually myconventionswork like
> before1.2, but if I call ExportTo() in my fluent configuration, noconventionsare applied.
>
> I can reproduce it by adding
> ".Conventions.Add(DefaultAccess.Property()).ExportTo("D:\\")" to
> Examples.FirstProject of the current 1.x branch. The exported mappings
> still contain the access strategies which are choosen by Fluent
> NHibernate itself (backfield for Id, nothing specified for other
> properties).
>
> On May 12, 9:45 pm, James Gregory <jagregory....@gmail.com> wrote:
>
>
>
> > I've tried to reproduce both of your issues and I can't. I modified the
> > Example.FirstProject and Example.FirstAutomappedProject example projects
> > which are included with the FNH source, and both of them applied table
> > namingconventionscorrectly.
>
> > *@dwlodarczyk* What version of FNH are you using exactly? You say1.2, was
> > that the official release or one of the pre-release builds? What's the build
> > version?
>
> > *@Vahid* Try upgrading to the1.2official release, the version you're
> > running is a few builds behind. I'm having no issues with the latest.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages