title: NHibernate performing a delete with Cascade.All causes N+1 deletes
body: <p>I have two entities Password and PasswordHash. Password has a collection of PasswordHashes (those are hashes with different masks).</p>
  
  <p>When I delete a Password I want all associated PasswordHash to be deleted as well.</p>
  
  <p>I did the mapping like this:</p>
  
  <pre><code>mapping.HasMany(x =&gt; x.PasswordHashes)
              .Cascade
              .All()
              .Inverse()
              .ReferencedBy(x =&gt; x.Password);
  </code></pre>
  
  <p>I expected the two queries to be generated:</p>
  
  <pre><code>DELETE FROM "PasswordHash" WHERE "IdPassword" = :p0
  </code></pre>
  
  <p>and obviously</p>
  
  <pre><code>DELETE FROM "Password" WHERE "IdPassword" = :p0
  </code></pre>
  
  <p>Instead NHibernate generated N+1 queries like this:</p>
  
  <pre><code>DELETE FROM "PasswordHash" WHERE "IdPasswordHash" = :p0 (N)
  </code></pre>
  
  <p>and</p>
  
  <pre><code>DELETE FROM "Password" WHERE "IdPassword" = :p0 (1)
  </code></pre>
  
  <p>How can I change this behaviour to be more optimal?</p>
  
  <p>EDIT: Code that deletes:</p>
  
  <pre><code>session.Delete(password);
  session.Flush();
  </code></pre>