NHibernate / ORM - Child Update over Web Service
- by tyndall
What is the correct way to UPDATE a child object with NHibernate but not have to "awake" the parent object. Lets say you would like to try to avoid this because the parent object is large or expensive to initiate.
Lets assume classes are called Author(parent) and Book(child). (still, trying to avoid instantiating Author)
Book comes back over a web service as XML. It gets deserialized back into a CLR object.
Book has an AuthorId property which allows this to happen. But it also has a Author property.
Problem, comes when you try to SaveOrUpdate() Book and the author_id in the database gets wiped out because the Author was null when the object gets deserialized. This seems like this would be a common problem. What is the workaround?
Also, if you instantiate the Author and it has a Books property. The book you are trying to update is already one of these books (List<Book>). We have also run into the
"a different object with the same identifier value was already associated with the session" problems. What is the standard process to update a child over a web service?