This project is read-only.


Persisting an entity causes session error in NHibernate (IIS7)


I have deployed my application to IIS7. On IIS6 (XP) it works ok. On IIS7, if I update an entity with relations I get the following error:
"Illegal attempt to associate a collection with two open sessions". It works ok for simple entities, without relations.
Reproduction steps: Go to the translations view, edit an item ans update it.
Kind Regards
Closed Sep 22, 2009 at 6:06 AM by Radim
This task seems to be more implementation oriented, then based on infrastructure of The Catharsis framework


Radim wrote Sep 9, 2009 at 5:39 PM

There are Catharsis built in 'service' objects AppUser and AppRole. When you are creating AppUse - also the 'related' collection AppRole is created. Is this working for you? On my Vista, when at least basic authentication is enabled - AppUser management works great. Therefore even the entities with relations are working.
Could you send more detailed description?
As I do remember my starts with NHibernate - such a message appears usally when you: 1) Open in one ISession (which is Request dependent) 2) stored in session (I mean the web-user-session -- not the NHibernate one), while request is closed (even during RedirectToAction) 3) And then 'as-transient' is appended to another Entity in next ISession. Then such a mishmash can happen...
From my experience with NHibernate - always try to do atomic operation in one ISession; avoid storing many entities in web-session before persisting them. It is very hard to correctly manage. - but this is only my suggestion

Radim wrote Sep 9, 2009 at 5:43 PM

The second thing to observe is the presence of the [Transaction] attribute on Controller's action. This will correctly open and commit the Transaction. Without 'Transaction attribute' changes won't be ever flushed!

wrote Sep 22, 2009 at 6:06 AM

wrote Feb 14, 2013 at 1:26 AM

wrote May 16, 2013 at 7:07 AM