Red Bottom Shoes NHibernate New item added to b

NHibernate New item added to bag collection doe Red Bottom Shoes s not get save Red Bottom Shoes d when updating parent entity

I’m using NHibernate version 3.1.0.4000 with hbm mapping files.

When I have an entity which contains a bag collection and i save the entity with all the items added to the bag then it s Red Bottom Shoes aves all the collection items fine. However, when i then subsequently (after the initial save) add another item to the collection and save the entity then it does not save the new item in the collection. I had a look at the SQL being generated by NHibernate and it creates the initial Insert SQL statement, but it does not create the Update SQL statement to update the foreign key value. This issue occurs for all ba Red Bottom Shoes gs in the solution.

It’s not clear in your code above if both parent and child are IAggregateRoot, but if they both are it means that, when you save the child in a session not aware of the parent, that the child will be saved fine but will not be added to the collection.

If you would use inverse=true, the child would be responsible for the relationship. In this case the model should be bidirectional and you should map both ends.