ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Expected lazy loading, got eager.
Date Sun, 07 Feb 2010 21:15:41 GMT
Are you running Beta 9?

If so, you might need to step through the code for us to see where it's
being called.

Also, ensure that your <settings> element enables lazy loading in your
configuration file (see the docs for more).

Clinton

On Sat, Feb 6, 2010 at 1:37 PM, Daryl Stultz <daryl@6degrees.com> wrote:

> Hello,
>
> I've got a mapper like this:
>
> <mapper namespace="model.UserMapper">
>
> <resultMap id="userResult" type="User">
>  <id property="id" column="user_id" />
> <result property="name" column="user_name" />
>  <association property="userType" column="user_usertypeid"
> javaType="UserType" select="model.UserTypeMapper.findById" />
>  </resultMap>
>  <select id="findById" parameterType="Integer" resultMap="userResult">
>  select userId as user_id, name as user_name, userTypeId as
> user_userTypeId
> from Users
>  where userId = #{id}
> </select>
>  </mapper>
>
> and another like this:
>
> <mapper namespace="model.UserTypeMapper">
>
> <select id="findById" parameterType="Integer" resultType="UserType">
>  select userTypeId as id, name
> from UserTypes
> where userTypeId = #{id}
>  </select>
> </mapper>
>
> 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 <setting name="lazyLoadingEnabled" value="true"
> /> 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
>

Mime
View raw message