I’m sure different ORM tools address the problem differently, but being brand new to the very concept of or-mapping, I’m not really concerned with a specific implementation as I am a generic solution. If its simply not possible to answer this question without a specific ORM framework, lets go with Hibernate.
I understand the basic premise of or-mapping, however I’m curious as to how these frameworks handle queries that span multiple tables, such as what occurs when JOINs are present in the query.
SELECT f.fizz_name, b.buzz_foo
FROM fizz f
INNER JOIN buzz b
ON f.buzz_id = b.buzz_id
WHERE b.buzz_bar < 10
Now we’re not getting a nice, clean, single POJO back from the or-mapper. I’m wondering if this is an area where or-mapping breaks down and straight-up JDBC is all a programmer has to work with.
I honestly gave this one a go by myself and couldn’t find anything in the Hibernate docs that indicated what happens in this kind of situation.
Thanks in advance!
As you point out, different ORM tools probably approach it differently, but in hibernate, you get a List of arrays back, where each column is an object in an Object[].
See section 16.6 here for more explanation.
The key point is you don’t need to use plain sql to get results from a join query, at least with Hibernate.