hibernate hql left join
I have the following query
select x.a, x.b, y.a, y.b
from x, y
where y.xid = x.id
how do I per开发者_开发百科form a left join here.
I cannot use the following style so please do not suggest the following.
select x.a, x.b, y.a, y.b
from x left join x.y as y
When you don't have a relationship between x
and y
, you can't express an outer join between them in HQL.
Thus, you have to create a relationship or use a native SQL query with left join.
If y
has a relationship to x
, you can rewrite left join as right join:
select ... from y y right join y.x x
精彩评论