Hi guys, I need some help in this modeling:

I have a Contact entity that is referenced in User, Company and any
other entity that needs contacts information. There are some
differences in these relationships, for example, a Company can has
more than one Contact but a User just one. So I model in this way,
Contact hasn't reference to any entity and User has a reference to
Contact. Here is the problem, I create the User and Contact entity,
set the new Contact to User.Contact and sent the User to NHibernate to
save, but here is the good error message: "not-null property
references a null or transient value Contact". I don't know, can
NHibernate trying to save the User before the Contact?

Can anyone say if my model is wrong or I probably don't configure the
mapping in the right way?

Here is the mappings

User
------
Id(x => x.Id);
Map(x => x.FirstName).Length(50);
Map(x => x.LastName).Not.Nullable().Length(50);
References(x => x.Contact).Not.Nullable();

Contact
-----------
Id(x => x.Id);
Map(x => x.Phone).Not.Nullable();
Map(x => x.Email).Not.Nullable();

Thanks, Victor

-- 
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.

Reply via email to