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 <da...@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:da...@6degrees.com
>

Reply via email to