Hibernate version:2.1.6
Hi;
This is my first question to this forum, since I had to do allot of reading before bothering people with questions :)
I have a strange reaction from hibernate, and I can't get it...
I have a class called "Shipment" it contains allot of info., another class called "ServiceAreaCode" that contain cities and so...
each Shipment contain 2 ServiceAreaCode objects, one is origin the other is destination...
simply... (This is a part of the map only)
Code:
<hibernate-mapping package="trackingApp.data">
<class name="Shipment" table="Shipment">
<id
column="shipmentID"
name="ShipmentID"
type="java.lang.Long"
>
<generator class="identity" />
</id>
<many-to-one
class="trackingApp.data.ServiceAreaCode"
name="OCodeID"
not-null="true"
>
<column name="orgCodeID" />
</many-to-one>
<many-to-one
class="trackingApp.data.ServiceAreaCode"
name="DCodeID"
not-null="true"
>
<column name="dstCodeID" />
</many-to-one>
.
.
.
now when I use only one ServiceAreaCode, it get eagerly fetched, but when I use both 2 calls are issued to the database, which make significant drop in performance.
Why? and how can I eagrly fetch these 2 objects? FetchMode doesn't work, I tried it.
I know some people would say that this is not a many-to-one relation ship, since there is 2 links to ServiceAreaCode, if my mapping is wrong, please correct me, but still I need the same logic.