开发者

hibernate hql left join

开发者 https://www.devze.com 2023-03-02 17:33 出处:网络
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 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
0

精彩评论

暂无评论...
验证码 换一张
取 消