I want to wrap my Hibernate BO's in a viewmodel object to adapt it to a form so that I can use databinding. I make a copy of my NHibernate BO for the ViewModel to work with. When the user clicks "Save", the viewModel attempts to copy the changes from the copy to the original NHibernate BO proxy. This allows me to have Cancel functionality. The problem is that the code to copy the changes from the duplicated BO to the original NHibernate BO looks suspisciously like the code I would have to write for mapping (predictable and boring: o.prop1 = c.prop1, etc).
It would be ideal if I could just use the working copy and discard the NHibernate proxy if the user clicks "Save." Assuming the working copy is an exact binary copy of the NHibernate proxy (cloned using binary serialization), if I attempt to update the copy using the Session will it assume it is a new object because the instance is not in the cache or will it identify it correctly based on it's ID? Will child collections still be updated effeciently?
|