Hi,

Are you using CGLIB? If not, iBATIS uses the Java
Proxy/Invocationhandler, which only handles interfaces. Somebody please
correct me if I'm wrong. If you look into EnhancedLazyResultLoader
you'll see that it does not only wrap instances of Collection.

Hope this clarifies something,

Niels

-----Original Message-----
From: Oleg Shpak [mailto:[EMAIL PROTECTED] 
Sent: donderdag 4 augustus 2005 18:21
To: [email protected]
Subject: Lazy loading

Hello,

I'm using lazy loading in iBatis, but this appears to fetch my object
eagerly, effectively increasing the number of statements to exactly N+1.
Lazy loading for collection does work however.
I did some research and found that iBatis does not create proxies for
objects, only for collections.

Am I missing something? After reading the docs I thought that lazy
loading applies to both objects and collections.

Here is what is going in
com.ibatis.sqlmap.engine.mapping.result.loader.LazyResultLoader, lines
66-74
----------------8<---------------
  public Object loadResult() throws SQLException {
    if (Collection.class.isAssignableFrom(targetType)) {
      InvocationHandler handler = new LazyResultLoader(client,
statementName, parameterObject, targetType);
      ClassLoader cl = targetType.getClassLoader();
      return Proxy.newProxyInstance(cl, LIST_INTERFACES, handler);
    } else {
      return ResultLoader.getResult(client, statementName,
parameterObject, targetType);
    }
  }
----------------8<---------------

The same is true for EnhancedLazyResultLoader

Thanks in advance,
Oleg






Reply via email to