Hibernate version: 3.1
Hi,
I am encountering a problem with bidrectional eager fetching (whether many-to-many or many-to-one) and do not know how to fix it.
I have 2 classes that are linked by a bidirectional many-to-many association: Product and Provider.
When I try to fetch (by load method) my Product object, I seem to get a cartesian join even though I specify to use the outer-join attribute (I can easily see this with the show_sql attribute).
If my relation is one sided, only one sql query is generated but when using a bidirectional association, I get a lot of sql queries
It is important to note that I do not wish to use lazy loading on my collections at this point.
Here are my mappings:
Code:
<set
name="providers"
table="PRODUCTS2PROVIDERS"
lazy="false"
cascade="none"
sort="org.mdarad.samples.totaltest.entities.ProviderComparator"
outer-join="true">
<key
column="PRODUCTS_FK"
>
</key>
<many-to-many
class="org.mdarad.samples.totaltest.entities.Provider"
column="PROVIDERS_FK"
outer-join="true"
/>
</set>
Code:
<set
name="products"
table="PRODUCTS2PROVIDERS"
lazy="false"
cascade="none"
sort="org.mdarad.samples.totaltest.entities.ProductComparator"
outer-join="true"
inverse="true">
<key
column="PROVIDERS_FK"
>
</key>
<many-to-many
class="org.mdarad.samples.totaltest.entities.Product"
column="PRODUCTS_FK"
outer-join="true"
/>
</set>
Any idea how I can fix this to have my eager fetch not end up as a cartesian join for my bidirectional associations?
Thanks,
Francois
Post rating: This posting has not been rated so far.