I want this 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'))
If I use alias for table2:
detachedCriteria.createAlias("table2", "t2");
and set like this:
detachedCriteria.add(Restrictions.eqProperty("t1.id2", "t2.id"));
Hibernate always generates INNER JOIN in SELECT query which I don't want and that gives me wrong results.
select count(*) as y0_
from
table1 this_
inner join
table2 table2_
on this_.id2=table2_.id
where
...
How can I achive "INNER JOIN" in WHERE clause (t1.id2 = t2.id) not in SELECT?