I've done some hacking on the LazyResultLoader class and came to a
working solution. I created an interface named "Deferrable" which is
basically just a marker interface. Properties which can be lazily loaded
on user defined types are typed as interfaces which extend Deferrable.
If a result loader for such a type is requested, the LazyResultLoader
will create a proxy for this type and lazy loading works.
Here is the modified code, maybe it is useful for someone else too.
Deferrable:
package com.ibatis.sqlmap.engine.mapping.result.loader;
public interface Deferrable {
}
loadResult() in LazyResultLoader:
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 if(targetType.isInterface() &&
Deferrable.class.isAssignableFrom(targetType)) {
InvocationHandler handler = new LazyResultLoader(client,
statementName, parameterObject, targetType);
ClassLoader cl = targetType.getClassLoader();
return Proxy.newProxyInstance(cl, new Class[] { targetType },
handler);
} else {
return ResultLoader.getResult(client, statementName,
parameterObject, targetType);
}
}