hibernate 查询笛卡尔积问题
今天写了一个hql作查询,结果查询出很多条重复的记录,肯定做了笛卡尔积,我一直很疑惑一个问题就是,怎样判断这个查询语句中是否一定会做笛卡尔积,我也做了表之间的关联,可能关联的不全也不知道怎么回事,怎么避免这种情况呢?我把控制台打印sql复制如下,哪位大牛了解的给小弟解析下,千恩万谢,我已经困惑很久了。
select
tkcbh0_.KCBHID as KCBHID38_,
tkcbh0_.CKDID as CKDID38_,
tkcbh0_.CKRK as CKRK38_,
tkcbh0_.CREATEDBY as CREATEDBY38_,
tkcbh0_.CREATEDTIME as CREATEDT3_38_,
tkcbh0_.CRKSJ as CRKSJ38_,
tkcbh0_.CRKSL as CRKSL38_,
tkcbh0_.CZR as CZR38_,
tkcbh0_.DElETEDBY as DElETEDBY38_,
tkcbh0_.DELETEDFLAG as DELETEDF6_38_,
tkcbh0_.DELETEDTIME as DELETEDT7_38_,
tkcbh0_.MODIFIEDBY as MODIFIEDBY38_,
tkcbh0_.MODIFIEDTIME as MODIFIED8_38_,
tkcbh0_.RKDID as RKDID38_,
tkcbh0_.WZID as WZID38_
from
t_kcbh tkcbh0_,
T_CKD tckd1_,
t_rkd trkd2_
where
(
tkcbh0_.DELETEDFLAG=0
)
and(
(
tckd1_.DJBH like '%6%' escape '/'
and tkcbh0_.CKDID=tckd1_.CKDID
)
OR(
trkd2_.DJBH like '%6%' escape '/'
and tkcbh0_.RKDID=trkd2_.RKDID
)
&