-->
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.  [ 4 posts ] 
Author Message
 Post subject: Laxy loading for one-to-one association not working
PostPosted: Sun Dec 12, 2004 1:36 am 
Newbie

Joined: Fri Oct 22, 2004 11:18 am
Posts: 9
Location: Lexington, KY
Hibernate version:
2.1.7

Mapping documents:
In the parent class called Unit I have the following assoc defined:

<one-to-one constrained="true" outer-join="false" name="unitAccounting" class="UnitAccounting" property-ref="unit"/>

The child class UnitAccounting is defined as follows:

<class name="UnitAccounting" table="UnitAccounting" lazy="true">
...
<many-to-one name="unit" class="Unit" not-null="true" column="birthMark" index="Idx_Fk_unit"/>

Code between sessionFactory.openSession() and session.close():
Executing a simple query against the Parent (Unit) always results in two queries, one against the parent Unit table and one against the UnitAccounting table. My expectation is that with constrained = true, fetching a Unit will result in a proxy for the UnitAccounting. I'm executing the following HQL query to test (in hibern8ide):

session.createQuery("from Unit").list();

I have read the FAQ and thought I had everything correct. Am I missing something?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 1:31 am 
Newbie

Joined: Fri Oct 22, 2004 11:18 am
Posts: 9
Location: Lexington, KY
I've been playing around with this and can't find anything that will prevent the extra query. In fact, even when I force outer-join fetching on the one-to-one attributes, it STILL does the extra select (in addition to doing the outer join in the query for the parent!!). I'm completely lost on this one and will have to start debugging the hibernate code to figure out exactly what the heck is going on?

Anyone out there have any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 1:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is a well-known problem with property-ref on a <one-to-one> in HB2.1. It was fixed in HB3.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 14, 2004 2:27 am 
Newbie

Joined: Fri Oct 22, 2004 11:18 am
Posts: 9
Location: Lexington, KY
Thanks Gavin.

We are planning on using hibernate3 for our production deployment late next year. I'll see if I can't get up and running with it and retest.

BTW, I hope I didn't miss this in the FAQ's, but I tried to dig around quite a bit. Seemed like using contrained="true" would fix it but no such luck. Thanks for the insight.

-Aaron


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.