我有HQL语句:
insert into Item (ost, value, comments, startTime, endTime, proposedBy)
select si.ost, si.value, si.comments, si.endTime, si.endTime, u
from Item si, User u
where si.ost = ? and u.id = ?
怎么可能被修改,而从ost
采取其他列使用参数的值startTime
和select
列?
无法在HQL进行;它不允许SELECT子句中的参数引用。
我不知道这最后的答案。我使用NH 3.2,我能得到这个工作
var hql = @"INSERT INTO EventFacility (Facility, Event, Owner, Position)
SELECT f, :evt, :own, :position from Facility f where f.Id IN (105, 109, 110)";
var @event = Session.Get<Event>(351931);
var query = Session.CreateQuery(hql)
.SetInt32("position", 0)
.SetEntity("evt", @event)
.SetEntity("own", @event.Owner);
var x = query.ExecuteUpdate();
Assert.AreEqual(3, x);
在这个例子中,我需要创建一个新的EventFacility对象。随着几乎所有的领域,你在这里看到。事件实体有另一个实体,业主挂关闭它。