select person3_.id as id1_6_, person3_.age as age2_6_, person3_.name as name3_6_, person3_.partnerDocument_id as partnerD4_6_
from Document document0_
left outer join document_version versions1_ on document0_.id=versions1_.document_id
left outer join (
select contacts2_.*, versions1_.idx as c_0_idx from contacts contacts2_ left outer join Person person3_ on contacts2_.contacts_id=person3_.id
) contacts2_ on document0_.id=contacts2_.Document_id and (contacts2_.contacts_KEY=contacts2_.c_0_idx )
left outer join Person person3_ on contacts2_.contacts_id=person3_.id