-->
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: Dynamically changing the Lazy option
PostPosted: Wed May 17, 2006 1:49 pm 
Newbie

Joined: Wed May 17, 2006 1:44 pm
Posts: 6
Code:
Configuration conf = getConfig();
        Iterator it = conf.getClassMappings();
        while (it.hasNext()) {
            org.hibernate.mapping.PersistentClass cl = (org.hibernate.mapping.PersistentClass) it.next();
            cl.setProxyInterfaceName(cl.getEntityName());
            cl.setLazy(false);
        }
        setSessionFactory(conf.buildSessionFactory());



All my Hbm.xml files are set default-lazy = "true"

In the code i amsetting lazy is false. But its not working..Its not returning data properly.
Can any one help me
thanks
Kasi


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 12:41 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
In what circumstances? default-lazy applies only in certain circumstances (hence "default" as opposted to "override" or "always"). It works when using Session.get/load, or when you've loaded an object with an assoication to the class in question, but not when you're querying the class directly via criteria or HQL.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 10:45 am 
Newbie

Joined: Wed May 17, 2006 1:44 pm
Posts: 6
Thanks a lot. Thats really good to know. Can you please let me know where can i find those kind of documentation. I really appreciate if you let me know the documentation.
Thanks
Kasi


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 5:42 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
As with many hibernate features, to figure out exactly what it means you have to read the entire ref docs, and lots of sample code. From refdocs section 6.1.2:

Quote:
default-lazy (optional - defaults to true): The default value for unspecifed lazy attributes of class and collection mappings.


So all it does it set lazy="true" anywhere that allows a lazy="" attribute but doesn't have one.

From refdocs section 20.1.2:

Quote:
The fetch strategy defined in the mapping document affects:

* retrieval via get() or load()
* retrieval that happens implicitly when an association is navigated (lazy fetching)
* Criteria queries


Note that HQL is not in this list.

And of course, experience and experimentaiton fills in the gaps in the docs. I can't find anything in the refdocs that explicitly says that critieria (usually?) ignore the lazy attributes in your mapping file, but I know that they do.

FYI, default-lazy="true" is the default (up to 3.0.. I think it's default-lazy="no-proxy" in newer releases, not certain). So you don't strictly need to put that in your mapping files, though it doesn't hurt and does serve in a sort of self-documenting role.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 5:48 pm 
Regular
Regular

Joined: Tue Nov 08, 2005 1:30 pm
Posts: 50
thanks


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.