下面是我的HQL的字符串
1 insert into OrderOnline.Model.sys.UserWorkAreaVO 2 (Product, SellPrice, ParValue, OrderType, AreaState) 3 SELECT x.Product, CAST(1 as Double), x.ParValue, x.OrderType, x.AreaState 4 FROM OrderOnline.Model.IWEC.WorkAreaVO as x 5 where 1 = 1 6 and x.ParValue = 0 7 and not exists (select y.Id 8 from OrderOnline.Model.sys.UserWorkAreaVO as y 9 where y.Product.Id = x.Product.Id 10 and y.ParValue = x.ParValue 11 and y.OrderType = x.OrderType 12 and y.User.Id = 2) 13 and exists (select y.Id 14 from OrderOnline.Model.ProductVO as y 15 where y.Id = x.Product.Id 16 and y.City.Parent.Id = 228 17 and y.City.Id = 2830) 18 and exists (select y.Id 19 from OrderOnline.Model.WorkListVO as y 20 where y.Id = x.Work.Id 21 and y.Id = 2) 22 and x.AreaState = 0 23 and x.OrderType = 2
执行下面的语句
_result = s.CreateQuery(_hql).ExecuteUpdate();
错误could not execute update query
提示的
列前缀 'IWEC_WorkArea' 与查询中所用的表名或别名不匹配。
列前缀 'IWEC_WorkArea' 与查询中所用的表名或别名不匹配。
列前缀 'IWEC_WorkArea' 与查询中所用的表名或别名不匹配。
列前缀 'IWEC_WorkArea' 与查询中所用的表名或别名不匹配。
列前缀 'IWEC_WorkArea' 与查询中所用的表名或别名不匹配。
产生的Sql语句是
insert into sys_UserWorkArea (Product_Id, SellPrice, ParValue, OrderType, AreaState) select workareavo0_.Product_Id as col_0_0_, cast(1 as DOUBLE PRECISION) as col_1_0_, workareavo0_.ParValue as col_2_0_, workareavo0_.OrderType as col_3_0_, workareavo0_.AreaState as col_4_0_ from IWEC_WorkArea workareavo0_ where 1 = 1 and workareavo0_.ParValue = 0 and not (exists (select userworkar1_.fid from sys_UserWorkArea userworkar1_ where userworkar1_.Product_Id = IWEC_WorkArea.Product_Id and userworkar1_.ParValue = IWEC_WorkArea.ParValue and userworkar1_.OrderType = IWEC_WorkArea.OrderType and userworkar1_.User_Id = 2)) and (exists (select productvo2_.fid from Product productvo2_, sys_Dictionary dictionary3_ where productvo2_.City_Id = dictionary3_.fid and productvo2_.fid = IWEC_WorkArea.Product_Id and dictionary3_.Parent_Id = 228 and productvo2_.City_Id = 2830)) and (exists (select worklistvo4_.Id from WorkList worklistvo4_ where worklistvo4_.Id = IWEC_WorkArea.Work_Id and worklistvo4_.Id = 2)) and workareavo0_.AreaState = 0 and workareavo0_.OrderType = 2
很奇怪的问题Hql的exists里面的明明是用x别名,为什么生成sql不是workareavo0_这个别名呢
不会
哥。句子复杂了用存储过程岂不更好
嗯,我也想用,不过我这里的条件不是固定的,就是where后面不是固定的,是根据用户选择的查询条件,比如exsts里面有个y.City.Parent.Id = 228,那就是用户选择了省份,如果也选择了城市就加 y.City.Id = 2830,
哎这种情况怎么结贴呢