Beginner |
|
Joined: Mon Nov 22, 2004 8:53 pm Posts: 23
|
I have a simple class mapping that has two one-to-many sets in it. Both sets have outer-join set to true. The sql that hibernate generates is single query for the base table and first set table and then an individual sql statement for the second set’s table. If I reverse the order of the sets in the mapping file, it reverses what table it joins in and which one it individually selects.
Is there any way to get it to put both joins in at the same time and execute only one query? I can by writing manual sql and it improves performance by more then 200%.
Thanks.
-peter
Mapping documents:
<class name="foo" table="foo" mutable="false" batch-size="50" optimistic-lock="none" lazy="false">
<id name="id" column="foo_id" type="integer">
<generator class="assigned"/>
</id>
<set name="bars" cascade="none" lazy="false" outer-join="true">
<key column="bar_id"/>
<one-to-many class="bar"/>
</set>
<set name="teas" cascade="none" lazy="false" outer-join="true">
<key column="tea_id"/>
<one-to-many class="tea"/>
</set>
…many other fields and a many-to-one mappings omitted…
</class>
<class name="bar" table="bar" mutable="false">
<id name="id" column="bar_id" type="integer">
<generator class="assigned"/>
</id>
..a couple simple fields omitted…
</class>
<class name="tea" table="tea " mutable="false">
<id name="id" column="tea_id" type="integer">
<generator class="assigned"/>
</id>
..a couple simple fields omitted…
</class>
Hibernate version:
2.1.7
Name and version of the database you are using:
Oracle9i
|
|