Thursday 7 June 2007

NHibernate:object references an unsaved transient instance

"object references an unsaved transient instance" recieved when performing a save (and transactional commit).
Caused by a related (parent) record not being saved and the entity not set up for cascading save.
e.g. User record has link to Person record but when user is saved the linked person is not saved.
Solution is either to turn on cascading saves for related entity or to explicity save the related record by creating a business object method.