I would like to write the following SQL in HQL so that it runs as a single statement:
update child_thingy c set c.parent_thingy_id = null where c.common_thingy_id = @common_thingy_id delete from parent_thingy p where p.common_thingy_id = @common_thingy_id
I translated SQL into HQL as follows:
update ChildThingy c set c.ParentThingy = null where c.CommonThingy = :commonThingy delete from ParentThingy p where c.ParentThingy = :commonThingy
I would like to run this as a single statement, but I cannot use CreateQuery and ExecuteUpdate in the same HQL block. I cannot run this in the MultiQuery and List block, as I get the following exception:
System.NullReferenceException: Object reference not set to an instance of an object. at NHibernate.Impl.MultiQueryImpl.AggregateQueriesInformation() at NHibernate.Impl.MultiQueryImpl.get_Parameters() at NHibernate.Impl.MultiQueryImpl.CreateCombinedQueryParameters() at NHibernate.Impl.MultiQueryImpl.List()
I cannot find the equivalent of MultiQuery ExecuteUpdate. Any ideas?
source share