select
*
from
t1 left join t2
on
(t1.a = t2.a and t1.b=t2.b)
or
select
*
from
t1 left join t2
on
t1.a = t2.a and t1.b=t2.b
[without parenthes]
t1 has a one-to-many relationship to t2 in column a (therefore, it has a “set” mapping from t1 to t2)
t1 has many-to-many relationship to t2 in column b (no matching yet)
case 1 :
b in t1 null, b in t2 null
case 2 :
b in t1 not null, b in t2 not null
case 3 :
b in t1 not null, b in t2 null
case 4 :
b in t1 null, b in t2 not null
How can I write the above SQL query in HQL?
I checked the "c" sentence in HQL. However, it expects a constant on the right side, not a column from a table.
To join another table in HQL, you need to have a mapping to this table.
My question is what is the neat way or the only way to achieve the above SQL in HQL?
t1 t2 (, t2 col a col b )?
, , . (, col b null , 2 "" ?)