-->
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: problem with one-to-one relationship with cyclical calls
PostPosted: Tue Apr 10, 2007 10:35 am 
Newbie

Joined: Wed Mar 14, 2007 10:16 am
Posts: 3
In Hibernate 3, I have a one-to-one relationship between two classes. I've followed the instructions from Java Persistance with Hibernate on pages 283 and 284. For one class, I have this:

<class name="FileCycleCurrent" table="FILE_CYCLE_CURRENT">
<composite-id class="FileCycleKey" mapped="true">
<key-property name="cycleDate" column="CYCLE_DATE"/>
<key-property name="fileId" column="FILE_ID"/>
</composite-id>
<property name="boxName" column="BOX_NAME"/>
<property name="updateCorpId" column="UPDATE_CORP_ID"/>
<many-to-one name="feedFile" class="FeedFile" column="FILE_ID" insert="false" update="false" unique="true"/>
</class>

In the other class, I have the following:
<class name="FeedFile" table="FEED_FILE_VW">
<id name="fileId" column="FILE_ID"/>
<property name="fileName" column="FILE_NAME"/>
<property name="expectedBusDate" column="EXPECTED_BUS_DATE" update="false" insert="false"/>
<one-to-one name="fileCycleCurrent" class="FileCycleCurrent" property-ref="feedFile"/>
</class>

I do a query again FileCycleCurrent and the jsp references fields in the FeedFile table. This all works correctly when displaying the page.

However, when I display the sql, I'm getting 3 sql statements when I only expect 2:
1) The query against FileCycleCurrent which is what the hql goes against.
2) The query against FeedFile which is run after the jsp page realizes it needs data from this table as well since lazy loading is being used.
3) A third query I don't expect is another query against FileCycleCurrent without the values in the HQL. It's like the FeedFile is getting this information again (Filecyclecurrent to feedfile and back to filecyclecurrent)

Why would the third query be running? It's pulling the same data as query 1 which is inefficient. Query 1 runs and if no data is pulled, queries 2 or 3 don't run. Since it's lazy loading I would expect query 2 not to run, but it shows that filecyclecurrent is doing something cyclical here.

I thought having the property-ref there says that it's inverse so it shouldn't do this.

Any idea why I'm getting this third query?

Thanks.


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.