2
我想這個SQL:內加入標準休眠
SELECT COUNT(*) FROM table1 t1, table2 t2
WHERE t1.id > 0
AND ((t1.name = 'foo')
OR (t1.id2 = t2.id AND t1.name = 'det'))
如果我使用別名表2:
detachedCriteria.createAlias("table2", "t2");
,並設置這樣的:
detachedCriteria.add(Restrictions.eqProperty("t1.id2", "t2.id"));
休眠總是生成INNER JOIN在我不想要的SELECT查詢中,這給了我錯誤的結果。
select count(*) as y0_
from
table1 this_
inner join
table2 table2_
on this_.id2=table2_.id
where
...
如何在WHERE子句(t1.id2 = t2.id)中不存在「SELECT INNER JOIN」?
這似乎是從table1到table2的左外連接,不是嗎? – oddparity