the problem is how you are using the session. you need 1 session factory per application. but sessions should be opened/closed only as needed. if you continue on the path of 1 session per application then you will be working against NH not with it.
On Dec 16, 8:39 am, DanV <[email protected]> wrote: > Hi, > > I'm involved in a project where I have a very particular scenario that > made me initially decide to use only one session per application. > Because of that, when I try to persist an entity in the database all > other entities that changed are also persisted (by flushing the > session). > > These are the facts and unfortunately (for me :)) some are not under > my control: > - 2 tier MDI app , developed over WPF. > - data binding is used bind entities to controls in windows. This > means that the entity is changed as the user operates in the GUI. > Canceling is done by reloading the entity. > - lazy loading is used so the session cannot just be closed. > - and the worst, entities and app windows are not hard coded but > generated based on a model (let's say a sort of UML). This means that > I don't have control over what and how is presented in the interface > or how entities are related. > - I cannot open a session for each window since there can be 2 windows > presenting somehow the same collection and that is not possible in > NH. > - I cannot use a separate new session to save an entity also because > NH does not allow same collection associated in 2 opened sessions. > > Problem: > - There can be a scenario where an user can open 2 windows, make > changes in both of them but incomplete/inconsistent in one of them and > hit save on the other where changes are complete.. Having only one > session means that all changes will be (or at least try to be) written > in db during Flush and for me that will be a problem in this > particular scenario :). > > Question: > -Is there any way to persist ony one entity (and whatever is cascading > with it of course) out of all entities cached in an ISession, while > the session is opened? -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
