ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Poitras Christian" <Christian.Poit...@ircm.qc.ca>
Subject RE: testing for lazy loading
Date Fri, 16 Jun 2006 14:28:13 GMT
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");
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.


From: Dodo [mailto:j2eedodo@gmail.com] 
Sent: Wednesday, 14 June 2006 18:00
To: user-java@ibatis.apache.org
Subject: testing for lazy loading

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 
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

View raw message