Castle.Facilities.NHibernateIntegration

348 views
Skip to first unread message

ross

unread,
Dec 19, 2011, 1:40:37 AM12/19/11
to Castle Project Development List
Hi All,

I posted on Stack Overflow previously as I was having trouble with the
NHibernateIntegration facility in Windsor when working alongside
Castle Windsor 3. The question is located at:

http://stackoverflow.com/questions/8557327/castle-windsor-3-fluent-nhibernate-castle-nhibernate-integration

I have since recompiled the NHibernateIntegration Facility DLL file
with a few changes to get it working and was wondering if this is
worth creating a patch for? The changes are:

For src\Castle.Facilities.NHibernateIntegration\Internal
\SessionFactoryActivator.cs:

Before: public override object Create(CreationContext context)
After: public override object Create(CreationContext context, Burden
burden)

For src\Castle.Facilities.NHibernateIntegration\Internal
\NHSessionComponentInspector.cs

Before: model.Dependencies.Add(new
DependencyModel(DependencyType.Service, null,
typeof(NHSessionInterceptor), false));

After: model.Dependencies.Add(new DependencyModel(null,
typeof(NHSessionInterceptor), false));

Thanks,

Ross.

ross

unread,
Dec 20, 2011, 8:19:03 PM12/20/11
to Castle Project Development List
Posted the issue and some patches to the issue tracker:

http://issues.castleproject.org/issue/FACILITIES-156

On Dec 19, 4:40 pm, ross <ross.cannizz...@gmail.com> wrote:
> Hi All,
>
> I posted on Stack Overflow previously as I was having trouble with the
> NHibernateIntegration facility in Windsor when working alongside
> Castle Windsor 3. The question is located at:
>
> http://stackoverflow.com/questions/8557327/castle-windsor-3-fluent-nh...

John Jeffery

unread,
Dec 20, 2011, 8:32:52 PM12/20/11
to castle-pro...@googlegroups.com
The project status page shows that the NHibernate facility currently has no
leader. Is this the case, or is someone actively supporting this facility?

Henry Conceição

unread,
Dec 20, 2011, 8:58:00 PM12/20/11
to castle-pro...@googlegroups.com
Yes, the facility currently has no leader, but it doesn't mean that
it's unsupported.

Cheers,
Henry Conceição

> --
> You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-d...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en.
>

John Jeffery

unread,
Jan 4, 2012, 10:10:43 PM1/4/12
to Castle Project Development List
Hi Ross,

What version of Castle.Services.Transactions were you using? I am
interested in getting the NH facility going as well, and I checked out
from the trunk and applied your patch.

All good so far, but I am also getting a compile error in src
\Castle.Facilities.NHibernateIntegration\Internal\ResourceAdapter.cs

The ResourceAdapter class implements an interface
Castle.Services.Transactions.IResource, which no longer exists in the
latest version of Castle.Services.Transactions (I used version
3.0.202.2202 from nuget). I have had a look around trying to work out
if this interface has been renamed or moved, but it would appear that
it has been completely removed. Any suggestions gratefully received.

Cheers -- John

ross

unread,
Jan 4, 2012, 10:21:53 PM1/4/12
to Castle Project Development List
Hi John,

I'm using an older version - 2.5.1.0- which still works ok.

The reason for this is because it compiles in .Net 3.5 which is a
requirement for the project I'm working on.

The 3.x version uses some .Net 4.0 specific features- I did manage to
replace most of them at one stage but due to time constraints didn't
get back around to it.

Cheers,

Ross.
> > > Ross.- Hide quoted text -
>
> - Show quoted text -

Henry Conceição

unread,
Jan 4, 2012, 10:43:30 PM1/4/12
to castle-pro...@googlegroups.com
Yeah, they (latest atm and nhib integration) don't play along together
anymore. You'll have to pick the 2.5 and update it to the latest
version.

Cheers,
Henry Conceição

Henry Conceição

unread,
Jan 4, 2012, 10:54:45 PM1/4/12
to castle-pro...@googlegroups.com
A simple update of tx the machinery doesn't work. At least if you want
to follow the guidelines preached by nhibernate (even with a ambient
tx, you must have begin session transaction). The simplest way it to
go with implicit session transaction (like henrik's facility does),
but it can lead to nasty dtc issues (from what i've read on blogs and
stackoverflow).

I'm trying to get they working together, but I'm not confident in
publish it atm. Want to test it a little more....

Cheers,
Henry Conceição

John Jeffery

unread,
Jan 5, 2012, 12:13:07 AM1/5/12
to Castle Project Development List
I was under the impression that the need to declare a session
transaction inside a transaction scope was fixed with NH 3.0 and
later? Do you think it is still necessary?

I for one would be very interested to see what you are doing with NH
integration with Castle Henry, if you ever get it to the point where
you want to show someone else.

Cheers -- John

Henry Conceição

unread,
Jan 5, 2012, 12:38:14 AM1/5/12
to castle-pro...@googlegroups.com
It's? Where did you saw it?

Cheers,
Henry Conceição

John Jeffery

unread,
Jan 5, 2012, 1:33:43 AM1/5/12
to castle-pro...@googlegroups.com
I read it a couple of places but have not done my own testing (yet) -- this
is a link to a fairly long blog entry about the problem. The author of the
blog posts a comment (right at the bottom, third-last comment) to the effect
that it is not a problem in NH3.1.

http://davybrion.com/blog/2010/05/avoiding-leaking-connections-with-nhiberna
te-and-transactionscope/


Cheers -- John

Henry Conceição

unread,
Jan 5, 2012, 2:42:54 AM1/5/12
to castle-pro...@googlegroups.com
Cool. I did some tests with this approach but since the
session.transaction was never active, i've assumed that the explict
session transaction management continued needed.

Cheers,
Henry Conceição

Reply all
Reply to author
Forward
0 new messages