-->
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: Additional Updates Fired While Using Indexed Collections
PostPosted: Mon Jun 16, 2008 10:31 am 
Newbie

Joined: Mon Jun 16, 2008 9:32 am
Posts: 2
Hi,

We are using:
Hibernate: 3.0
MySQL: 5.0.27
JBoss: 4.0.5
Java: J2SDK 1.4.2_08

We are facing a Database performance issue while implementing bidirectional mapping between two classes (LogRecordCache and LogRecord with relation: A LogRecordCache can have a List of LogRecords). Their hibernate mappings are as shown below:

1. ------ Mapping for LogRecordCache -----

Code:
       
   <class name="LogRecordCache" table="wsc_log" lazy="false">      
      
<id name="logId" column="logid" type="long">
         <generator class="assigned" />
      </id>      
      ...
      <list name="logs" lazy="false" cascade="save-update">
         <key property-ref="logId" column="logid"  />
         <index column="indexcolumn" type="int"/>
         <one-to-many class="LogRecord"/>
      </list>      
      ...
   </class>


2. ------ Mapping for LogRecord -----

Code:

   <class name="LogRecord" table="wsc_logrecords">      
      <id name="logRecordId" column="logrecordid" type="string">
         <generator class="uuid.hex"/>
      </id>
                ...
      <many-to-one lazy="false" name="logRecordCache" column="logid" property-ref="logId"/>
               ...
   </class>



we have observed that while saving an instance of LogRecordCache additional update queries are issued. So, instead of issuing N+1 queries (1 query to insert LogRecordCache, and N queries to insert N LogRecord in it), 2N+1 queries (with N additional updates) are issued. Ofcourse, these additional updates are used for populating the index column for the indexed collection (LogRecordCache's indexcolumn) and the foreign key (LogRecord.logId in our case).
Note that the updates are fired even when we use a bag, just that they update the foreign key(logId in our case) only.

Please suggest some way so that updates are not fired or indicate that this is default Hibernate behavior and if possible also why (gavin ????).

Thanks,
Rupesh.


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.