5

I would like to improve my code when deleting a group of objects in NHibernate (V3). Currently, I iterate on a retrieved collection and I call delete on each object. This generates n+1 SQL statements.

I notice that NHibernate Session provides this method : Delete(string query)

By using this method I think I can do the same thing with a single SQL statement.

Do you know if there is a way to combine this method with QueryOver API to avoid HSQL ?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
fxkim
  • 363
  • 1
  • 5
  • 11

1 Answers1

2

As far as I know the only way to do single-shot deletes and updates is using HQL. As a compromise, you might want to take a look at this workaround.

Community
  • 1
  • 1
Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275