Quantcast
Channel: Development With A Dot
Viewing all articles
Browse latest Browse all 404

NHibernate Pitfalls: HQL Delete Does Not Cascade

$
0
0

This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.

When you issue an HQL delete statement over an entity, you may be surprised to find out that it will not cascade to any configured associations it may have:

   1: session.CreateQuery("delete from Order o where o.Id = :id").SetParameter("id", 10).ExecuteUpdate();

If you really want to cascade associations, you will have to load the entity explicitly and then call ISession.Delete() upon it.


Viewing all articles
Browse latest Browse all 404

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>