This is part of a series of posts about NHibernate Pitfalls. See the entire collection here.
While I was writing Deleting Entities in NHibernate, I noticed that actually it referred some pitfalls concerning deleting, so I decided to add them to the proper collection.
There are several ways to delete entities in NHibernate, as you can see in the referenced post. The problems with each approach are:
Using Executable HQL: no cascade to related associations occurs, no events are raised;
Using Delete with an entity proxy: forces loading of all cascaded lazy associations before deleting; requires a Flush to apply changes (if it needs to be explicit or not depends on you flush settings);
Using Delete with a query string: all items are loaded into the session (not a single DELETE statement), no cascade occurs, no events are raised, no notification about the number of affected records and also requires a flush.