I have the following model: user belongs to an account M:1 account has an owner 1:1 account has many users 1:M the owner of an account is also belongs to that account.
mapped with FNH mapping.References( user => user.Account ) .Column( "AccountId" ) .Cascade.All(); ( where mapping is AutoMapping<User> ) mapping.References( account => account.Owner ) .Not.Nullable(); mapping.HasMany( account => account.Users ) .KeyColumn( "AccountId" ) .AsBag() .Inverse() .CascadeAllDeleteOrphan(); ( where mapping is AutoMapping<Account> ) If I set up an object graph containing 1 user and 1 account where the user owns the account ( and is also a member of the account's users ), NH will save the graph with no issues if I use session.Save ( account ), but will fail if I use session.Save( user ) with a PropertyValueException "not null property references a null or transient value Account.Owner" I have 2 questions: 1. Is there a better way to model the concept of an account having an owner that is also one of the accounts users? 2. Why is NH able to correctly deduce it must save the owner then the account then update the owner if I ask it to save the account, but not if I ask it to save the user (owner)? Any insights greatly appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
