NHibernate 的 BUG?

liqianhong 2007-03-25 02:28:52
Voucher12 和Voucher11 继承 VoucherEntity
VoucherEntity 包含属性 ID,CanPrint

Voucher12 包含一属性HandleCharge 为 Voucher11的实列

有这样一个HQL
From Voucher12 v Where v.CanPrint = true or v.HandleCharge.CanPrint =true
结果所有 Voucher11里 CanPrint=true的记录全被关联起来了
并不象期望的那样

From Voucher12 a inner join Voucher11 b
where a.ID = B.ID and ( a.CanPrint =true or b.CanPrint = true)


产生的结果和这个差不多
From Voucher12 a inner join Voucher11 b
where ( a.ID = B.ID and a.CanPrint =true ) or b.CanPrint = true)

...全文
245 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
liqianhong 2007-03-29
  • 打赏
  • 举报
回复
From Voucher12 v Where v.CanPrint = true or v.HandleCharge.CanPrint =true
生成 sql 为

select ..
from voucherdata12 a inner join voucherinfo b on a.id = b.id,
voucherdata11 c inner join voucherinfo d on c.id = d.id
where b.canprint = 1 or (d.id = b.id and d.canprint=1)

不是我们期望的那样,
where d.id = b.id and (b.canprint = 1 or d.canprint=1)

liqianhong 2007-03-29
  • 打赏
  • 举报
回复
我看了一下,和我说的情况不一样,那个例子是多表更新的问题.
而我的这个例子是生成的sql语句不对造成的
roapzone 2007-03-28
  • 打赏
  • 举报
回复
http://www.cnblogs.com/Roping/archive/2007/03/27/689805.html

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧