Hi all, I've the following sqlmap for ibatis 2. Suppose ibatis has its lazy-loading feature enabled and I obtain a user U by means of findUserById. Then I call U.getEmail() and findMemberById is not executed. That's fine, one wouldn't expect the associated member to be loaded until there is a real need for it. Of course, if then I call U.getMember().getDescription() findMemberById does execute its select, in due time. That said, for ibatis 3 the same example executes findMemberById as soon as U.getEmail() is invoked, loading the member before time. That's not surprising if one inspects the code of ResultObjectProxy (relevant parts copied below). Is this intended to work the way it does or is it a bug?
<sqlMap namespace="User"> <resultMap id="userMap" class="User"> <result property="email" column="email"/> <result property="member" column="member_id" select="findMemberById"/> </resultMap> <resultMap id="memberMap" class="Member"> <result property="description" column="description"/> </resultMap> <select id="findUserById" resultMap="userMap"> select * from qpoint_user where id = #id# </select> <select id="findMemberById" resultMap="memberMap"> select * from cpp_member where member_id = #id# </select> </sqlMap> public class ResultObjectProxy { public Object invoke(Object o, Method method, Object[] args) throws Throwable { try { if (!Object.class.equals(method.getDeclaringClass()) && PropertyNamer.isGetter(method.getName())) { lazyLoader.loadAll(); <-- this loads all asociations for every getter invoked on this proxy } return method.invoke(target, args); } catch (Throwable t) { throw ExceptionUtil.unwrapThrowable(t); } } } Regards -- Bardamu --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org