hi all - I've ran into an interesting performance bump - would appreciate community's input on the issue. We have a legacy schema (DB2/400, 5.4) and pretty much 99% of all columns are CHAR that are padded with spaces (instead of nulls). So, in the actual table you can see column values like
Code:
' '
. The problem arises when we try to load an entity that has an "empty" (not quite empty, there are spaces there, so for CHAR(5) there will be
Code:
' '
) reference to another table. Eg. I have a DealerOrder entity that has many-to-one to VehicleBasic class and when DealerOrder.VIN is 17 spaces, it tries to find a corresponding VehicleBasic with id=' ' (17 spaces) - no surprises here. It becomes interesting when I'm fetching a hundred of such orders - it takes a lot of time - I've never managed to wait it finishes - all I can see is smth. like
Code:
2010-09-21 13:54:50,610 DEBUG [org.hibernate.loader.Loader] - done entity load
2010-09-21 13:54:50,610 DEBUG [org.hibernate.engine.TwoPhaseLoad] - done materializing entity [com.application.DealerOrder#434132]
2010-09-21 13:54:50,610 DEBUG [org.hibernate.engine.TwoPhaseLoad] - resolving associations for [com.application.DealerOrder#434133]
2010-09-21 13:54:50,610 DEBUG [org.hibernate.loader.Loader] - loading entity: [com.application.VehicleBasic#component[header,indicator]{header= , indicator= }]
When the DealerOrder reference existing VehicleBasic objects, they load instantenously - I also tried adding an "artificial" empty row to database to let Hibernate find "empty" references - it helps but I feel this is more a workaround rather than fix. Please see attached my mapping file:
Code:
<class name="DealerOrder" table="DO" lazy="false" batch-size="3">
<id name="orderNumber" column="OR" type="string" />
<property name="releaseDate" type="date" column="DTEREQ" not-null="true"/>
<property name="requestMonth" type="string" column="REQMTH" not-null="true"/>
<component name="model">
<property name="modelCode" type="string" column="MDL" not-null="true"/>
<property name="doors" type="string" column="DOOR" not-null="true"/>
<property name="transmission" type="string" column="TRAN" not-null="true"/>
<property name="grade" type="string" column="GRADE" not-null="true"/>
<property name="colour" type="string" column="COL" not-null="true"/>
<property name="year" type="string" column="YEAR" not-null="true"/>
</component>
<property name="deliveryNumber" type="string" column="DLVNO" not-null="true"/>
<property name="toWarehouse" type="warehouse" column="TOWH" not-null="true"/>
<property name="schedulingWarehouse" type="warehouse" column="SCHWH" not-null="true"/>
<property name="orderStatus" type="orderStatus" column="OS" not-null="true"/>
<many-to-one name="vehicle" class="VehicleBasic"
not-found="ignore" not-null="false" lazy="false" fetch="join">
<column name="VINH" />
<column name="VINI" />
</many-to-one>
<many-to-one name="purchaseDealer" column="PRDLR" not-found="ignore" fetch="join" not-null="false" lazy="false" />
<many-to-one name="deliveryToDealer" column="DLVCD" not-found="ignore" fetch="join" not-null="false" lazy="false" />
<many-to-one name="invoiceToDealer" column="INVDLR" not-found="ignore" fetch="join" not-null="false" lazy="false" />
</class>
What would be the correct way of dealing with such a problem? What are other options? Thank you.