I'm having trouble with a native query which I formulated as:
"SELECT si.inst_number, c.name, feat.name, " +
"a.POSTALCODE, a.CITY, a.STREET, a.STREETNO " +
"FROM institution si " +
"inner join FEATUREITEM feat on si.STATUS=feat.ID " +
"left outer join CONTACTS c on si.INST_CONTACT_ID = c.ID " +
"left outer join address a on c.id = a.contact_id " +
"WHERE length(si.INST_NUMBER) > 5 ORDER by si.inst_number";
The problem is, that the returned object[] has the same values for two columns in object[1] and object[2].
If I put the SQL into a SQL Tool and let it process, this brings the right values.
It seems to me that Hibernate is confused by "c.name" and "feat.name" and it sees only "name". Is that true?
And: do you think it is better to use JPA-QL here? If, how can I formulate it. I have the following associations:
Institution -> Contact -> Address, where Address may appear more than once for one Contact, whereas Institution has exactly one Contact.
Any suggestions welcome!
Carlo
|