Using Hql or criteria, how can I update many rows and set a property to false?
ie. SQL would be:
UPDATE UserOrders SET isDeleted = 0 -- (boolean false) WHERE uID = 234
Using Hql or criteria, how can I update many rows and set a property to false?
ie. SQL would be:
UPDATE UserOrders SET isDeleted = 0 -- (boolean false) WHERE uID = 234
If you do not use the business object in any other way for this, I think I would bypass NHibernate in this situation. That is: do not use HQL, but issue a native SQL query. (NHibernate allows you to do this; check the CreateSQLQuery of the ISession).
Why would I do that ? Because, when you issue such a query using HQL, I think that NH will fetch every entity out of the database, change its property, and then update its corresponding row. Imagine the performance hit. But, I think that HQL does not support UPDATE queries (but I could be mistaken on that one).