subqueries in hibernate
Posted on 2004-09-28
I have a table with approximately 80 columns, of which about 40 are references to other tables. They are defined as <many-to-one ... /> in hibernate mapping file.
When hibernate generates sql it uses "outer left join" keywords and generates a huge SQL clause. It takes about 20 seconds to execute this query.
I am using Oracle and using subqueries in select statements improves the performance greatly.
Here is my question:
How can I make Hibernate 2.1 use sub-select statements instead of huge joins?
Eg. hibernate generates this
select person.name, city.name from T_PERSON person, T_CITY city
And I want hibernate to generate this
(select city.name from T_CITY city where city.code = person.city) as city_name