2009-10-27 106 views
4
string query = "update User u set u.PointsTotal = 1 join u.Rounds r where r.RoundId = :round and (r.Row1 & :val) > 0"; 

NHibernateSession.CreateQuery(query) 
    .SetByte("val", (byte)val) 
    .SetInt32("round", roundId) 
    .ExecuteUpdate(); 

只是給了我「給定的密鑰不在字典中」。在Hibernate中使用HQL更新查詢

是的,關係正常工作,可以做的選擇....

回答

5

好的解決了這一,好像你必須做一個子查詢......

string query = "update User u set u.PointsTotal = 1 where u.Id in (select u2.Id from User u2 join u2.Rounds r where r.RoundId = :round and (r.Row1 & :val) > 0)"; 

NHibernateSession.CreateQuery(query) 
    .SetByte("val", (byte)val) 
    .SetInt32("round", roundId) 
    .ExecuteUpdate(); 
+0

艾柯!我一直在尋找這兩天!非常感謝! :-) – zakmck 2013-04-08 14:47:18