haf / Castle.Facilities.NHibernate

The NHibernate Facility supercedes NHibernateIntegration and integrates with the new Transaction support. Please read http://stackoverflow.com/questions/4010265/how-to-let-nhibernate-retry-deadlocked-transactions-when-using-session-per-reque before using, it will help you.
https://github.com/haf/Castle.Facilities.NHibernate/wiki
Apache License 2.0
15 stars 23 forks source link

Do transactions work at all without MSDTC? #13

Closed PandaWood closed 10 years ago

PandaWood commented 11 years ago

I'd really like to hear from someone who's got this project working (using SQLServer) because no matter what I do I cannot get barely a single object to persist using this project - having come from using NHibernateIntegration which worked perfectly.

I have the most simple of cases now. Where I use SessionPerTransaction I call a single controller method in MVC4 which has a [Transaction] attribute on the method. In that method is almost nothing but a call to Session.OpenSession().Delete(obj). And immediately I get this MSDTC server not running exception. This never (and probably cannot possibly happen) using NHIbernateIntegration.

If I start the MSDTC server, in this case, the Delete works, but I cannot have this new dependency. Why does it rely on distributed transaction services in the most simplest of cases like this? Has anyone got this working without relying on this MSDTC happening to be running?

haf commented 11 years ago

The unit tests run without MSDTC afaik. Try those?

PandaWood commented 11 years ago

Apart from the mult-threaded cases - all the unit tests pass (the readme.txt says need MSDTC & they time out for me)

I can't help feel there must be something missing, in a real-world scenario, that the Quick-Starts aren't telling us ;-) I've rolled my own situation back to using NHibernate.Integration. I've had to put [Transactional] & [Transaction] attributes back on, but the simple case I mentioned above, now works again (the transaction is begun & committed and no MSDTC exceptions)

One example of this kind of thing, that I worried about was, is how could the Facility's SessionPerWebRequest lifestyle work without registering the PerWebRequestLifestyleModule in web.config - which isn't mentioned anywhere in the Quick-Starts?

I'm just guessing, but there might be some sort of config/setup/assumption like this that is required that I'm not aware of and that the unit tests don't cover.

My scenario is specifically that using SessionPerWebRequest or using [Transaction] attribute, within an MVC app, doesn't create any transactions - once I've registered NHibernateFacility, created an installer class etc. And since I'm coming from having used NHInt, one can assume I'm using ISessionManager and having it injected etc in basically the same way.

At some point, I'll create a small MVC app, with the bare essentials to replicate my scenario and we'll see if that helps find the problems I'm having.

PandaWood commented 10 years ago

FYI I never did get this to work and rolled back to using NHibernateIntegration