NHibernate RRS feed

  • Question

  • Hi guys, I recently created a POC for Entity Framework and now trying to do some research on NHibernate.  I have come across a few statements stating that NHibernate is not suited for a stateless environment ( without any information behind why.  I understand the issue with Entity Framework and entities not traveling well outside the scope of the ObjectContext, however you can always attach the objects later and mark them as modified so the SaveChanges() method picks them back up on the way back from the web app.  Can someone with NHibernate experience elaborate on whether these statements I've heard are true and if so what is the difference in behavior between EF and NH in a stateless environment.

    Thank you.
    Thursday, July 16, 2009 11:52 AM

All replies

  • I presume you're concerned with the cost of creating a Nhibernate session. I admit I've not used NHibernate a lot but I would guess that it is a good idea to keep hold of the ISession so it can track the objects within. If you drop the ISession, as you'd typically do in a stateless environment, then you loose the tracking and therefore a big chunk of the features. As far as I can tell it's not unlike the issues with ObjectContext, I'm looking forward to someone else doing a better job of explaining it.
    Thursday, July 16, 2009 9:48 PM
  • I was chatting with a Nh fan the other day about object tracking. It seems that both technologies share the same approach, don't hold the object tracking across the session but rather recreate/refresh the state on the way back. The adv. is more about ensuring that during a complex set of changes the identity of an object is properly tracked, i.e. you change a value in it and that is reflected by whatever else next uses it...but only during the session that is saving it back. I do remember some tutorials about WCF Data Services that used both Nh and EF, although using an abstracted repository is certainly frowned upon these days.
    Monday, May 2, 2011 10:22 PM