-->
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: lazy=true and lazy=proxy
PostPosted: Sun Jul 03, 2005 2:03 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
Hibernate version:
3.0.5

For many-to-one and one-to-one, H3.0.5 allows lazy=true and lazy=proxy - What is the difference?

I understand if it is a value type, there is no "proxy" per se and lazy=true requires bytecode instrumentation. However, when the referred property is a user defined class type, what is the difference between true and proxy?

The reason I ask this question is that lazy=true and lazy=false behaves differently (which I don't think it makes sense). I have Class A which has a many-to-one relationship with class B (unidirectional). Originally I defined lazy="true" and it worked fine with H3.0.2. However, if I upgrade to H3.0.5 - it does not work anymore: H3.0.5 eagerly fetching Class B when A is persistent although I defined lazy=true in many-to-one and defined B as a lazy object at class level. Then I changed to lazy="proxy" and lazy fetching worked.

In the mapping file, I did define class B as a lazy obejct.

So what's the differenc betwen lazy=proxy and lazy=true in H3.0.5?

Please also note that H3.0.2 generates an error if lazy=proxy was specified -
Quote:
Error parsing XML: XML InputStream(221) Attribute "lazy" with value "proxy" must have a value from the list "true false ".
H3.0.5 fxed it.

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 2:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The documentation was updated to relect this change.
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-manytoone

Anyway, lazy (optional - defaults to proxy): By default, single point associations are proxied. lazy="true" specifies that the property should be fetched lazily when the instance variable is first accessed (requires build-time bytecode instrumentation). lazy="false" specifies that the association will always be eagerly fetched.

Lazy=true on the relationship is a field level proxy (hence the build time enhancement) while lazy=proxy (the default) leave lasy loading trigger to the referenced object, egm class level proxy. Lazy=false allows the class level proxy domain object to be not lazy loaded (eg, eagerly) for this relationship.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 11:25 am 
Beginner
Beginner

Joined: Thu Mar 03, 2005 9:19 pm
Posts: 22
David,

Thanks for your eply but I have seen the documentation and I understood the difference between field level and object level.

As I mentioned in my precious post, The reason I asked this question is that lazy=true and lazy=false behaves differently for Object Level property. For H3.0.5, if I specifies lazy=true, it actually eagerly fetching the referred object (H3.0.2 will not) - I have to remove the lazy specification or set lazy to default, which is proxy.

My question is, is this intended behavior (by new design)?

I also noticed H3.0.5 has some different fetching behavior when it comes to fetch a object graph - it is different (probably the default fetch depth) but I have not verified yet - I am trying some experiments. The reason I say it is H3.0.5 is that my app works fine with H3.0.2 and after my upgrade to H3.0.5, I see difference.

I hope somebody else has similar experience and can share in this thread.

Again, I appreciate your prompt reply.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 11:34 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This was an alignment with EJB3 fetching behavior and is mentioned in the changelogs.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 03, 2005 11:35 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Oh, and the documentation was of course also updated. So you might want to read that again for 3.0.5.


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.