-->
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.  [ 3 posts ] 
Author Message
 Post subject: Nested classes (lazy="false") not always fully loa
PostPosted: Mon Jul 25, 2005 8:58 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
My app does a lot of work with "owned" objects, so many classes use many-to-one mappings to a single Owner class. In all my queries (HQL and plain old load/get) the joins are working great. However when I have two levels of indirection to an owned object, its owner isn't fully loaded: the id is populated, but all other fields are left at their defaults.

So if I load owned object A, owner X, and A has a many-to-one/unique mapping to owned object B, owner X, then B.getOwner() is returning an Owner object with a valid getId() but everything else uninitialized. A.getOwner() is fine, as are all other fields in A and B.

Incidentally, why aren't I getting the same pojo for the two different owners? They have the same id, and they're coming from a single session.load() call. If I got more reuse of my Owner objects I'd be very happy.

I've verified that the generated SQL in complete (in the above example, the Owner table is joined to twice) and I've run the SQL and the results are good; it's just that the non-id fields in the second Owner join aren't retrieved into the pojo.

I'd be happy with a "read the manual" response, if it included chapter numbers and maybe some sample code :)


Top
 Profile  
 
 Post subject: Problem seems to be fetch="join"
PostPosted: Mon Jul 25, 2005 10:23 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
In experimenting to find a solution myself, I have found that loading (from my above example) object B via fetch="select" instead of fetch="join" solves everything perfectly. Perhaps there's an issue loading two objects of the same type and/or key from a single select statement? If there is, I can raise a JIRA issue about it. In fact, I'll check now to see if the problem has already been reported.


Top
 Profile  
 
 Post subject: JIRA issue
PostPosted: Mon Jul 25, 2005 10:41 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
I couldn't find anything like this in JIRA so I've created HHH-790 for it.


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