Делаю такой NativeSQL запрос:
SELECT *, @C := @C + 1 AS `top` FROM
(
SELECT *, @C := 0 FROM
(
SELECT * FROM
(
SELECT s.*, s2.priority AS `priority` FROM `server` s
LEFT JOIN servers_services ss ON (s.id = ss.server_id)
LEFT JOIN service s2 ON (s2.id = ss.service_id)
WHERE s.is_banned = 0 AND s.is_vip = 1 AND ss.service_id IS NOT NULL
ORDER BY priority DESC
) server_with_vip_with_services
UNION
SELECT * FROM
(
SELECT s.*, s2.priority AS `priority` FROM `server` s
LEFT JOIN servers_services ss ON (s.id = ss.server_id)
LEFT JOIN service s2 ON (s2.id = ss.service_id)
WHERE s.is_banned = 0 AND s.is_vip = 0 AND ss.service_id IS NOT NULL
ORDER BY priority DESC
) server_without_vip_with_services
............
RSM:
$rsm = new Query\ResultSetMapping();
$rsm->addEntityResult('Game\ServerBundle\Entity\Server\Server', 's');
$rsm->addFieldResult('s', 'id', 'id');
В итоге:
Notice: Undefined index: id
500 Internal Server Error - ContextErrorException