-->
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: 3.1rc returns porxies on load by default?
PostPosted: Fri Oct 21, 2005 2:08 pm 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
Hibernate version: 3.1rc2

For some reason, when I try to load (session.load) an object by default hibernate creates a proxy for h. Is there a way to dissable the default behavior to do non-proxy (throw an exception instead) other than putting

@Proxy(lazy=false)

for every class? It worked but it is a lot of busy work to go thru each class and do that.

BTW: I also tried to put it on superclass and that did not work.

Thanks,
Alex


Top
 Profile  
 
 Post subject: Re: 3.1rc returns porxies on load by default?
PostPosted: Fri Oct 21, 2005 3:02 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
session.get() doesn't use proxies the same way load() does.

The only difference between the two, beside the proxy issue, is that load() will throw an Exception if the Object isn't found and get() will simply return NULL.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 3:08 pm 
Beginner
Beginner

Joined: Tue Nov 25, 2003 3:33 pm
Posts: 35
I was just surprised thathibernate would do it by default. But get should it for me. thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 21, 2005 3:11 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
ashneyde wrote:
I was just surprised thathibernate would do it by default. But get should it for me. thanks.


Read section 11.3 (in the 3.0.5 docs) for a detailed explanation.

The reason for the proxy for known objects is that it allows you to associate an object with another without actually doing the database call if you don't need to.

For example, you know that PERSON_TYPE_ID=1 indicates that the Person Object is for a Client, as opposed to an Employee. You could create a new Client Object, set it's personType attribute to the Proxy of PersonType id=1, and save it without having to ever read the PERSON_TYPE row from the database.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


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.