I have two entities, a Company and an Address. The Company has two addresses, the mainAdrress that is required and the postalAddress that is optional (both configured as OneToOne). Now I need a list with all my companies and their city names for both addresses. I use this query:
SELECT c.displayName, c.mainAddress.city, c.postalAddress.city FROM Company c
select companyent0_.displayName as col_0_0_, addressent1_.city as col_1_0_, addressent2_.city as col_2_0_ from Company companyent0_, Address addressent1_, Address addressent2_ where companyent0_.mainAddress_primaryKey=addressent1_.primaryKey and companyent0_.postalAddress_primaryKey=addressent2_.primaryKey