-->
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.  [ 2 posts ] 
Author Message
 Post subject: Efficient update of columns - select-before-update
PostPosted: Mon Aug 08, 2005 11:59 am 
Newbie

Joined: Mon Aug 08, 2005 11:19 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I'm a hibernate newbie - and so far I've found it to be a great concept and a great tool.

I'm working in a 3-tier web/ ejb architecture using the auto-flushing and auto session closing, and container managed transactions. Fantastic stuff.

I have an object A with several sets of children say B, C and D.

The user goes to the details page for A - and hibernate loads up A in its entirety using an HQL query (outer join fetch) to retrieve all the child sets.

Beautiful.

The user updates A and submits from the browser.

I've used select-before-update="true" and dynamic-update="true" to get Hibernate to write an efficient update statement for only the columns that have changed.

However when hibernate does this select it does separate selects for each of the Collections that form A.

Is there any way to tune Hibernate to use outer join fetching when it does this select-before-update ( as it does when I run the HQL query)

I've tried setting fetch="join" on each of the many-to-one mappings - but to no avail.

Any help much appreciated

Hibernate version: 3.05

Name and version of the database you are using: SQL Server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 09, 2005 5:14 am 
Newbie

Joined: Mon Aug 08, 2005 11:19 am
Posts: 5
A couple more things to add:

I've changed the fetching strategy on my object graph to use outer join fetching (non-lazy).

When I load the parent object using
session.load()
the whole graph is loaded in one select - as expected.

So I think that I've got my mapping files correct.

Abbreviated Mapping Files:


Code:
<class name="Owner" dynamic-update="true" select-before-update="true" lazy="false">
       .....
       <set name="dogs" inverse="true" cascade="save-update" fetch="join">
         <key column="ownerID" />
         <one-to-many class="Dog"  />
      </set>
      <set name="cats" inverse="true" cascade="save-update" order-by="sampleID desc" fetch="join">
         <key column="ownerID"/>
         <one-to-many class="Cat" />
      </set>
      <set name="logHistory" inverse="true" cascade="save-update" order-by="id asc" fetch="join">
         <key column="ownerID" />
         <one-to-many class="LogEntry"/>
      </set>
   </class>
   <class name="LogEntry" lazy="false">
                 ....
      <many-to-one name="owner" column="ownerID" fetch="join" />
   </class>
   <class name="Dog" dynamic-update="true" select-before-update="true" lazy="false">
         ....
        <set name="favoriteFoods" inverse="true" cascade="save-update" fetch="join" >
         <key column="dogID"/>
         <one-to-many class="FavoriteFood"/>
      </set>
      <many-to-one name="owner" column="ownerID" fetch="join"/>
   </class>
   <class name="FavoriteFood" dynamic-update="true" select-before-update="true"  lazy="false">
            .....
             <many-to-one name="dog" column="dogID" fetch="join" />
   </class>
   <class name="Cat" dynamic-update="true" select-before-update="true" lazy="false">
            .....
      <many-to-one name="owner" column="onwerID" lazy="false" fetch="join"/>
   </class>



So my question is: should the automatic select-before-update obey the configured fetching strategy? If so, can you suggest what I'm doing wrong?

Thanks in advance for any help


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

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.