Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 63367 invoked from network); 6 Feb 2010 20:38:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 6 Feb 2010 20:38:03 -0000 Received: (qmail 42437 invoked by uid 500); 6 Feb 2010 20:38:02 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 42357 invoked by uid 500); 6 Feb 2010 20:38:01 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 42349 invoked by uid 99); 6 Feb 2010 20:38:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Feb 2010 20:38:00 +0000 X-ASF-Spam-Status: No, hits=-0.6 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [64.18.2.6] (HELO exprod7og117.obsmtp.com) (64.18.2.6) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 06 Feb 2010 20:37:51 +0000 Received: from source ([209.85.223.171]) by exprod7ob117.postini.com ([64.18.6.12]) with SMTP ID DSNKS23TClLnds2cZmBOGpslg1WHS8ac4dZh@postini.com; Sat, 06 Feb 2010 12:37:31 PST Received: by iwn1 with SMTP id 1so445967iwn.24 for ; Sat, 06 Feb 2010 12:37:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.59.7 with SMTP id j7mr2744979ibh.12.1265488650398; Sat, 06 Feb 2010 12:37:30 -0800 (PST) Date: Sat, 6 Feb 2010 15:37:30 -0500 Message-ID: Subject: Expected lazy loading, got eager. From: Daryl Stultz To: iBatis user group Content-Type: multipart/alternative; boundary=001485ea8c56796bf6047ef489a3 --001485ea8c56796bf6047ef489a3 Content-Type: text/plain; charset=ISO-8859-1 Hello, I've got a mapper like this: and another like this: So User has a many-to-one association with UserType. When I run this: user = userMapper.findById(123); these 2 queries are executed: select userId as user_id, name as user_name, userTypeId as user_userTypeId from Users where userId = ? select userTypeId as id, name from UserTypes where userTypeId = ? So it looks like user.userType is being eagerly loaded. How do I set things up to be lazy loaded? I have even though the default is true. I have confirmed that my classes are being enhanced by CGLIB. Thanks for the help. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:daryl@6degrees.com --001485ea8c56796bf6047ef489a3 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

I've got a mapper like this:

<mapper namespace=3D"model.UserMapper">
=

<resultMap id=3D"userResult" type=3D"User"= >
<= id property=3D"id" column=3D"user_id" />
<= span class=3D"Apple-tab-span" style=3D"white-space:pre"> <result= property=3D"name" column=3D"user_name" />
<= association property=3D"userType" column=3D"user_usertypeid&= quot; javaType=3D"UserType" select=3D"model.UserTypeMapper.f= indById" />
<= /resultMap>
<select id=3D"findById" parameterType=3D"= Integer" resultMap=3D"userResult">
sele= ct userId as user_id, name as user_name, userTypeId as user_userTypeId
fro= m Users=A0
wher= e userId =3D #{id}
</select>
</mapper>

and another like this:
<= br>
<mapper namespace=3D"model.UserTypeMapper"&= gt;

<select id=3D"findById" parameterType=3D&qu= ot;Integer" resultType=3D"UserType">
sele= ct userTypeId as id, name=A0
from UserTypes=A0
where userTypeId =3D #{id}=
</= select>
</mapper>

So User has = a many-to-one association with UserType. When I run this:

user =3D userMapper.findById(123);

=
these 2 queries are executed:

select use= rId as user_id, name as user_name, userTypeId as user_userTypeId from Users= where userId =3D ?
select userTypeId as id, name from UserTypes where userTypeId =3D ?

So it looks like user.userType is being eagerly load= ed. How do I set things up to be lazy loaded? I have=A0<setting name=3D&= quot;lazyLoadingEnabled" value=3D"true" /> even though th= e default is true. I have confirmed that my classes are being enhanced by C= GLIB.

Thanks for the help.

--
D= aryl Stultz
_____________________________________
6 Degrees Software = and Consulting, Inc.
http://www.6deg= rees.com
mailto:daryl@6degrees.com
--001485ea8c56796bf6047ef489a3--