First, enable logging in iBatis.
This will tell you when your List is loaded in memory.
 
Have code like this.
System.out.println("Get object");
User user = (User) dao.getUser(new Long(1));
System.out.println("Should see a query for your list below");
user.getList().size();
 
If you see the query for your list before the last comment, then lazy loading does not work and you need some modifications to enable it.
 
 
Btw, I don't know how you could have a better time in non-lazy loading.... Maybe you should pre-populate the List, since it doesn't seem to have to many elements...
The main reason I can guess is the first initialization of a subclass for your lazy object. This initialization should be run only once. So in 2 calls, you could get a better performance.
 
Christian

From: Dodo [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 14 June 2006 18:00
To: [email protected]
Subject: testing for lazy loading

Hi,
 
How do I test for lazy loading to assure myself that
it's working?
 
I did some test as below where user has complex collection as List
 
     long start = System.currentTimeMillis();
     
    User user = (User) dao.getUser(new Long(1));
     long elapsedTimeMillis = System.currentTimeMillis()-start;
     log.warn( "time: " + elapsedTimeMillis );
 
 
I compared the result with lazyLoadingEnabled="false" and
lazyLoadingEnabled="true"
 
For lazyLoadingEnabled="true", I got time: 62
For lazyLoadingEnabled="false", I got time: 46
 
Funny thing is for 'true' scenario, it takes longer. Is that normal?
I 'd expect shorter time since complex collection is not loaded
 
THanks
 
 
Sam

Reply via email to