-->
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.  [ 5 posts ] 
Author Message
 Post subject: how to understand "proxy" in "class"?
PostPosted: Mon Apr 19, 2004 11:07 pm 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
In charpt 12: Performance, section 1:
Article introduces "proxy" attribute in node "class". But I am not understand the usage, specially, how to lazy initilaze an ordinary association?
Can somebody post an example to demonstration it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 11:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Could you please be a little more clear?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 11:42 pm 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
I wanna find a way to lazy initialize association like many-to-one, one-to-one if I do not use infomation about association object in a case. But probably I would use these infomation in another case. So I configue the association in xml and want to lazy init it. The best way is I can configure lazy or not(out join other table or not) dynamic.
I read this charpt to find a way to fulfill my requirment. But it seems not giving a sample to show how to lazy an association. And I also not understand the different between using proxy or not.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 19, 2004 11:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Well, proxy is the way to lazy init a single multiplicty association.

For the sake of argument, say you have a User class mapped and a Group class mapped. Further, say a User can be associated at most one Group and that you want the user's Group information loaded lazily. So basically you'd map this as:

Code:
<class name="Group" table="group" proxy="Group">
    ...
</class>

<class name="User" table="user">
    ...
    <many-to-one name="group" class="Group" .../>
</class>


Now, when hibernate loads the User object its reference to Group will be a lazy proxy.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 12:11 am 
Regular
Regular

Joined: Wed Dec 03, 2003 9:41 pm
Posts: 87
OK. I see.
I set out-join="true" before, so I get same query process. Does it mean I should configure out-join="false" and proxy together? Because I find if I set out-join="true", it will query using join and query association object at one time.
For some cases I should join many table using outer-join to decrease sql statement. For some cases I lazy initialize association when I do not need. Can I dynamic configure out-join="true" for proxy?


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