You will have to save the user first then assign the group to the user and save that.
You will have to save the user first then assign the group to the user and save that: using (var session = factory.OpenSession()) { User you = new User() { Name = "test"}; session. SaveOrUpdate(u); Group g = new Group() { GroupName = "Test Group", User = you }; session. SaveOrUpdate(g) } I have found that you cannot cascade save child /parent related objects which have only just been created.
This is exactly what I have done as a work-around. However I would have thought that this type of parent-child relationship is fairly common and would therefore be catered for. – Dion Nov 2 '10 at 19:48.
I recently had this exact type of mapping working fine in a project. My advice is: Learn how the Inverse attribute of a HasMany relationship works. Great explanation here You need a two way association between the parent and child object.
This is explained at the bottom of the article linked to above. Another good advice is to encapsulate your collections better - Don't access your collections modification methods directly. The collection properties should be read-only and the parent (User class in your case) should have AddGroup() and RemoveGroup() methods that changes the private collection.In order for this to work you have to let Nbernate access the private collection member by using the .Access.
CamelCaseField(Prefix. Underscore) or similar mapping attribute. Good discussion about it here I can post an example mapping and class files if needed.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.