I can define multiple phone numbers for a contact. Phones are a sorted collection, each phone has a preferrence (int pref) which allows to select primary (preferred) contact with a subquery in a select clause:
select c.first_name, c.last_name, c.birth_date,
(select ph.value from phone ph where ph.contact_id = c.id order by ph.pref limit 1)
from contact c
How can I achieve the same with JPQL, without using the native queries? The LIMIT
keyword is not supported by JPQL.