我想获取连接一些实体,以避免很多额外的查询,我也想得到相关集合的数量。
像这样的东西:
SELECT u, a, count(p) properties_count
FROM User u
JOIN u.address a
LEFT JOIN u.properties p
group by u.id
那就是我想得到像[[0 => User, 'properties_count' => 42], [0 => ...], ...]
这样的集合。
它没有获取连接(SELECT u, count(p) properties_count
),但使用SELECT u, a, count(p) properties_count
它似乎不包括结果中的计数。
难道我做错了什么?
看起来它只是原始查询中的一个错误。
它使用这样的连接:
LEFT JOIN Address a WITH a.id = u.address
当我把它换成了
LEFT JOIN u.address a
它开始工作了。 (我认为他们是等价的)