我正在尝试在 HQL 中执行右外连接。查询创建如下所述:
Query query = this.sessionFactory
.getCurrentSession()
.createQuery(
"select
O.customer.id as id,
O.customer.firstName as firstName,
O.customer.lastName as lastName,
O.customer.address as address,
O.customer.city as city,
count(O.id) as totalOrders
from
Order O
right outer join O.customer
group by
O.customer.id");
mysql 上的 SQL 查询工作正常,但 HQL 查询正在返回内部连接的结果。
SQL查询是:
select c.id,
c.firstname,
c.lastname,
c.city,
count(o.id) as total_order
from orders o right outer join customers c
on c.id = o.customer_id group by id