-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: performance problem with <any> mapping
PostPosted: Sun Jan 01, 2006 5:03 pm 
Newbie

Joined: Mon Nov 07, 2005 6:11 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.05

Mapping documents:

Code:

<hibernate-mapping default-lazy="false" package="edu.mayo.gensupp.hmm.businessobject">

<class name="InventoryItem"
      table="hmmtb_inventory_item">

   <id name="id" type="int" column="inv_item_id">
       <generator class="org.hibernate.id.MultipleHiLoPerTableGenerator">
           <param name="table">hmmtb_next_id</param>
           <param name="primary_key_column">nxt_pk_col</param>
           <param name="value_column">nxt_pk_value</param>
           <param name="primary_key_value">inv_item_id</param>
           <param name="primary_key_length">30</param>
         <param name="max_lo">1</param>
       </generator>
   </id>
   
   <many-to-one name="inventory" class="Inventory" column="inv_id" />
   <property name="itemType" type="string" column="item_type" insert="false" update="false" />
   
   <any name="item" id-type="int" meta-type="string">
       <meta-value value="P" class="Product"/>
       <meta-value value="U" class="UnreviewedItem"/>
       <column name="item_type"/>
       <column name="item_id"/>
   </any>
   
   <!-- unit of measure may not be known -->
   <many-to-one name="unitOfMeasure" class="DropdownValue" column="inv_item_uom_id" not-found="ignore" />
   <property name="qty" type="float" column="inv_item_qty" />
   <property name="effectiveDate" type="calendar" column="inv_item_eff_date" />
   <property name="expirationDate" type="calendar" column="inv_item_exp_date" />
   <property name="notes" type="string" column="inv_item_notes" />
</class>



This InventoryItem class contains an object that can either be an instance of Product or UnreviewedItem, with the type determined by the item_type field. I almost shed tears of joy when I saw how painless Hibernate made this to implement.

Unfortunately the performance is terrible. Hibernate is issuing a select statement for each InventoryItem object to get its corresponding item. I tried setting the batch-size attribute directly in the any mapping and in the Product and UnreviewedItem classes and it was ignored in all places. I tried fetching the items via an inner or outer join and got null pointer exceptions when Hibernate tried to parse the query.

My questions here are a) why is the batch-size attribute ignored for this mapping type, and b) is this really the most efficient way to get the mapped objects? Why can't Hibernate do a batch fetch of each mapped type and union the results together (i.e. fetch all items of type 'P' union fetch all items of type 'U')?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.