How can this be done with (N)Hibernate?
Posted
by Vilx-
on Stack Overflow
See other posts from Stack Overflow
or by Vilx-
Published on 2010-03-15T14:27:30Z
Indexed on
2010/03/15
14:29 UTC
Read the original article
Hit count: 217
I'm creating a windows forms application with NHibernate. It's an MDI application, so there is no limit to how many forms the user can have open at the same time (probably many).
For most forms I want to have an "OK" and a "Cancel" button. Both close the form, but "OK" also saves the modified data to the DB. The forms can be pretty complex, and the modifications are likely to touch a whole graph of objects, adding some, deleting some, and changing some more. It would be good if the changes could be automatically detected and persisted as needed, without the need to manually keep track of each of them.
What would be a good way to do this?
Extra information: I can make whatever DB schema I want. I'm using MSSQL 2008 and currently have decided for GUID primary keys (with guid.comb generator) and a TIMESTAMP column for optimistic concurrency.
I tried to simply set FlushMode
of a NHibernate ISession
to Never
, doing all modifications as needed, and then calling Flush()
if the user clicked OK. But that didn't work.
© Stack Overflow or respective owner