NHibernate 3.2+ and FluentNHibernate and Castle

108 views
Skip to first unread message

MattO

unread,
Jul 2, 2012, 12:06:19 PM7/2/12
to nhusers
Folks,

NHibernate 3.2 includes it's own proxy now, and you don't need to use
Castle anymore. However FluentNHibernate defaults to Castle in the
latest version (1.3).

So how do you get these two to play together?

I see one option is:

.ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory,
NHibernate")

By placing that setting before you do the FluentNHibernate
BuildSession.

Is it even possible to use Castle anymore? Should I even try?

Why is Castle still default in FluentNHibernate?

Oskar Berggren

unread,
Jul 2, 2012, 12:08:46 PM7/2/12
to nhu...@googlegroups.com
I'm currently on 1.3.0.729 from
http://teamcity.codebetter.com/viewType.html?buildTypeId=bt9&tab=buildTypeStatusDiv
with NH3.3 and didn't have do to anything special, except on upgrade
from NH 3.1 I _removed_ my own configuration line that said to use
castle.

/Oskar


2012/7/2 MattO <xan...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "nhusers" group.
> To post to this group, send email to nhu...@googlegroups.com.
> To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
>

MattO

unread,
Jul 2, 2012, 12:48:28 PM7/2/12
to nhu...@googlegroups.com
I got the latest from the NuGet repository.
 
My version is 1.3.0.733 (later then yours).
 
According to the code here in the latest version it's still looking at Castle:
 
> To unsubscribe from this group, send email to nhusers+unsubscribe@googlegroups.com.

Oskar Berggren

unread,
Jul 2, 2012, 1:02:09 PM7/2/12
to nhu...@googlegroups.com
But do you get any actual error? From a cursory glance it looks unused.

The relevant part of my bootstrapping seems to work:
FluentConfiguration configuration = Fluently.Configure()
                 .Database(MsSqlConfiguration.MsSql2005.ConnectionString(connectionString))
                 .Mappings(m => ...)
                 .BuildSessionFactory().
           
/Oskar


2012/7/2 MattO <xan...@gmail.com>
To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/62bLujGiicUJ.

To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.

MattO

unread,
Jul 2, 2012, 1:41:27 PM7/2/12
to nhu...@googlegroups.com
Don't get the error after putting in the following code before BuildSessionFactory():
 
fluentConfiguration.ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory,
NHibernate");
 
Here is the code that sets things up (from s#arp arch):
 
fluentConfiguration.Mappings(m =>
 {
  foreach (var mappingAssembly in mappingAssemblies)
 {
 var assembly = Assembly.LoadFrom(MakeLoadReadyAssemblyName(mappingAssembly));
 m.HbmMappings.AddFromAssembly(assembly);
 m.FluentMappings.AddFromAssembly(assembly)
  .Conventions.AddAssembly(assembly);
 }
if (autoPersistenceModel != null)
 {
 m.AutoMappings.Add(autoPersistenceModel);
 }
});

fluentConfiguration.ProxyFactoryFactory("NHibernate.Bytecode.DefaultProxyFactoryFactory,
NHibernate");
 
return fluentConfiguration.BuildSessionFactory();
Matt
Reply all
Reply to author
Forward
0 new messages