NHibernate parent-childs save redundant sql update executed


I'm trying to save (insert) parent object with a collection of child objects, all objects are new. I prefer to manually specify what to save\update and when so I do not use any cascade saves in mappings and flush sessions by myself. So basically I save this object graph like:

session.Save(Parent) foreach (var child in Parent.Childs) { session.Save(child); } session.Flush()

I expect this code to insert Parent row, then each child row, however NHibernate executes this SQL:

INSERT INTO PARENT.... INSERT INTO CHILD .... UPDATE CHILD SET ParentId=@1 WHERE Id=@2 //What the point of update if ParentId was set in previous query

This update statement is absolutely unnecessary, ParentId was already set correctly in INSERT. How do I get rid of it? Performance is very important for me.


I forgot "Inverse" in mappings on many-to-one collection.


  • How to pass the id of the parent to the create view of a child
  • Wordpress Get value of queried category in URL
  • droppable in droppable
  • XML - XSLT - document() function inside count() function
  • Issue with session.handler.native_file session handler in symfony2
  • PHP Post & Redirect with cURL Same As HTML Form [closed]
  • Standard way for writing a debug mode in C++
  • ZF2 Doctrine: When to flush ObjectManager
  • K Shortest Path Python Not Working
  • IP and domain create different session
  • Rely on Facebook user id as a permanent user identifier
  • java.io.EOFException when sending serialized data to a servlet
  • Input buffer flush
  • jQuery and Uploadify session in the php file
  • How to handle empty space in url when downloading image from web?
  • How to add learning rate to summaries?
  • Ruby and class variables in inherit class
  • Insertion large number of Entities into SQL Server 2012 [duplicate]
  • Double dispatch in Java example
  • How to Save JSON data to SQL server database in C#?
  • Most efficient way to move table rows from one table to another
  • C#: Import/Export Settings into/from a File
  • Force show.bind execution
  • Eloquent paginate function in Slim 3 project using twig
  • How can I set a binding to a Combox in a UserControl?
  • How can I extract results of aggregate queries in slick?
  • AJAX Html Editor Extender upload image appearing blank
  • Is there a way to do normal logging with EureakLog?
  • PHP buffered output depending on server setting?
  • Disable Enter in editText android
  • How to delay loading a property with linq to sql external mapping?
  • Debugging ASP.NET on a built-in web server suddenly stops
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Linking SubReports Without LinkChild/LinkMaster
  • Bitwise OR returns boolean when one of operands is nil
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • How to get NHibernate ISession to cache entity not retrieved by primary key