-->
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.  [ 1 post ] 
Author Message
 Post subject: Disable lazy loading. setLazy(false)
PostPosted: Thu Nov 11, 2004 6:25 am 
Newbie

Joined: Thu Nov 11, 2004 6:03 am
Posts: 1
Hello All

I have two applications which use same object model and I need to use lazy loading in one application and don't use it in another. I need to implement this functionality with minimal changes in code and I don't like to generate different mappings for different applications(I do so now).

I've read here about following solution:

Quote:
If you like to disable/enable some setting globally, you might rebuild the SessionFactory after modifying the metadata from the Configuration programatically. This is easier than it sounds, get all PersistentClass objects from Configuration (the API), loop over all collections and setLazy(true). Then, build a new SessionFactory from this Configuration.


and tried to ipmpement it:

Code:
Configuration cfg = ConnectionFactory.createConfiguration(theProperties);
cfg.configure();

// Disable lazy loadings
for(Iterator iterator = cfg.getCollectionMappings(); iterator.hasNext();)
{
     Collection collection = (Collection)iterator.next();
     collection.setLazy(false);
}

ConnectionFactory.sessionFactory = cfg.buildSessionFactory();


and it doesn't work. My questions are:

1. what am I doinng wrong?
2. how can I implement this functionality in another way? Eager fetching is not suitable for me because I have more then one collections in my objects.[/i]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.