-->
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: how to set eager fetch for the whole class in annotation
PostPosted: Wed Oct 26, 2005 12:27 am 
Newbie

Joined: Fri Apr 29, 2005 11:55 pm
Posts: 14
Location: China-Australia
I try to convert my hbm.xml to annotation, and I have one problem.

Here's my definition:


<class name="FirmUser" lazy="false">
...
</class>

<class name="Interview">
<many-to-one name="firmUser" column="firm_user_id"
class="FirmUser" lazy="no-proxy"/>
...
</class>


And here's how I retrieve an Interview instance


Interview interview =
(Interview)session.load(Interview.class, interviewId);
interview.getFirmUser();


I closed the session after the above code segment, and all fields of FirmUser have been retrieved.

But when I switch to Annotation, I got a
could not initialize proxy - the owning Session was closed
error on one of the property of FirmUser

and I can see from hibernate generated sql, it didn't make a query to FirmUser table, while it suppose to do it cos I explicitly called getFirmUser() while session was opened.

And I'v noticed that same thing happend when I use a hbm.xml file but
with lazy="true" in the class FirmUser attibute.

So, is their any way in Annotation to set the whole class to eager retrieval?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 6:03 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@Proxy(lazy=false)

_________________
Emmanuel


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.