-->
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: Help: Join Fecthing Not working!
PostPosted: Fri Sep 16, 2005 8:06 am 
Newbie

Joined: Sun Aug 28, 2005 3:06 am
Posts: 9
Hibernate version: 3.0

Dear Hibernate Team,
We’re having a problem with join fetching. The bottom line is that after specifying the fetch=”join” in the hierarchy of objects that we need to fetch using get/load;
1. We save the Object “InvPo” with its child Set “InvPoItems” wrapped in parent.
2. After save, we use load to get the object with other associations. Load() gives the InvPo and Child Set “InvPoItems” from cache.
3. But when we access the “InvNdcLocation”, it only gives the PK of entity and throws Null Pointer Exception on accessing any other attribute.
4. Further objects in hierarchy are not accessible.
5. If not using the cache (load in second transaction), it shows the Lazy Loading Initialization Exception.

Following is the hierarchy of objects that we wish to fetch.

Entity: InvPo
<set name="invPoItemsSet" fetch="join" inverse="true" cascade="all" >
<key column="NM_PO_ID"/>
<one-to-many class="InvPoItems"/>
</set>

Entity: InvPoItems
<many-to-one name="invNdcLocation" column="NM_NDC_LOCATION_ID" class="InvNdcLocation" fetch="join" />

Entity: InvNdcLocation
<many-to-one name="invNdcListing" column="NM_NDC_LISTING_ID" class="InvNdcListing" fetch="join" />


Entity: InvNdcListing
<many-to-one name="oncDrgDetail" column="ONC_DRG_DETAIL_OID" class="OncDrgDetail" fetch="join"/>


Using .load(class, serializable) method, it is not fetching the desired objects.

Can anyone guide us on how to resolve this issue?

Thanx and Regards,
Wasif


Top
 Profile  
 
 Post subject: lazy="false"
PostPosted: Fri Sep 16, 2005 12:13 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Try adding lazy="false"
i.e.
<many-to-one name="invNdcLocation" column="NM_NDC_LOCATION_ID" class="InvNdcLocation" fetch="join" lazy="false"/>

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject: fetch="join" still not working
PostPosted: Tue Sep 20, 2005 6:17 am 
Newbie

Joined: Sun Aug 28, 2005 3:06 am
Posts: 9
I useed the tag lazy="false" along with fetch="join", but it is not working.

An important point is according to the article "A Short Primer On Fetching Strategies (http://www.hibernate.org/315.html)", there is no need of using lazy="false". Because, if lazy="false" is used the HQL query will retrieve extra data which is not required. Two options are available

1. lazy="false" and fetch="select"
2. fetch="join"

But option 2 is not working, even with lazy="false".


Regards,
Wasif


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 22, 2005 2:06 pm 
Newbie

Joined: Tue Aug 09, 2005 7:02 pm
Posts: 7
I have the same problem. I can verify with the generated SQL that the join is performed and looking at the debug output I see a line like this:

Code:
2005-11-22 18:34:36,470 DEBUG [org.hibernate.loader.Loader] done processing result set (33 rows)
2005-11-22 18:34:36,470 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close ResultSet (open ResultSets: 1, globally: 1)
2005-11-22 18:34:36,470 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-11-22 18:34:36,470 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-11-22 18:34:36,470 DEBUG [org.hibernate.loader.Loader] total objects hydrated: 73


But after that hibernate still wants to initialize the one-to-many collections with a SQL for each parent object. Although all child objects were already initialized.

I set
Quote:
hibernate.max_fetch_depth = 3


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.