I need help converting this SQL (which works):
select c.last_name, c.first_name, np.first_name FullFirst
from dggs_project.contact c left join dggs_project.contact np on np.preferred_name_id = c.contact_id
where c.preferred_name_id is null
order by c.last_name
;
to HQL.
Contact is the hibernate object.
I tried this:
select c, npc from Contact c, Contact npc
where npc.contact = c
but that runs out of memory. the npc alias refers to the "child". preferred_name_id gets mapped to "contact", an instance of Contact inside Contact.
preferred_name_id is null for the parent. I don;t like reflexive joins but I have to deal with this legacy database!
|