Hibernate Team |
|
Joined: Tue Jun 13, 2006 11:29 pm Posts: 315 Location: Calgary, Alberta, Canada
|
Without calling Root.Children.Add(Child), Child would not get added to the Root.Children collection. With the exception of when the entity is loaded, NHibernate does not do anything automatically; you as the programmer are responsible for ensuring that the in-memory object associations are correct. In this case, setting Child.Parent but not add Child to the Root.Children violate that.
Now the direct answer to your question is that you may call session.Refresh(Root) to reload the state from the database. Having said that, Refresh() is typically used only to sync up with the database only when there are externally-triggered things to be synced up -- such as a timestamp field or effects of triggers. Synching up a relationship as in the example/test you have given is not typical usage and it is discouraged.
_________________ Karl Chu
|
|