Dear ladies and sirs.
We use NHibernate as our ORM on the server side.
Sometimes, there is a need to delete an object from the database, given only the type and ID of that object. In addition, the deleted object was not fetched before (so it is not in the session cache or whatever).
Anyway, I am using the ISession.Delete(query)
overload, where the query is as trivial as from Dummy where Id=5
.
My question is why does NHibernate fetch the object before deleting it? As far as I can see I am paying for the double round-trip to the server for an operation, which intuitively should take just one round-trip.
Is there a way to delete an object from the database by its type and ID with NHibernate, so that it takes just one round-trip?
Thanks.