You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Dodo <j2...@gmail.com> on 2006/06/14 16:31:49 UTC

lazy loading

Hi guys,

Can someone show me how lazy loading is achieved in ibatis?
I have a hard time finding any concrete example on this.

E.g.

Category class has a List of Item, each Category can potentially contain thousands
of Items.

Now is enabling lazy loading as simple as following?
  
If it is, is accessing it as simple as calling the Category's POJO getter method to return
a list of Item objects, i.e.  category.getItems()???

<sqlMapConfig>
 
  <settings
   ...
   lazyLoadingEnabled="true" <!-- lazy loading -->
   ...
  />
 
  .....
</sqlMapConfig>
  
Or do I have to specify something else?


  
Thanks,

Sam
  

Re: lazy loading

Posted by Dodo <j2...@gmail.com>.
Hi X,

That's not really lazy loading, it's dynamic conditional loading but I guess 
it will do for the same thing.

According to page 7 and 9 of the same doc,

<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="128"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"
/>

lazyLoadingEnabled is 'true' by default, exactly how does this lazy loading 
work?

The doc seems to lack in this. For example,

<resultMap id="get-category-result" class="com.ibatis.example.Category">
   <result property="id" column="CAT_ID"/>
   <result property="description" column="CAT_DESCRIPTION"/>
   <result property="productList" column="CAT_ID" select=" 
getProductsByCatId"/>
</resultMap>

.......

<statement id="getProductsByCatId" parameterClass="int" resultMap="get-product-result">
   select * from PRODUCT where PRD_CAT_ID = #value#
</statement>

Now if productList contains 10000 products, does resultMap 
'get-category-result' load
productList by lazy loading when called??

Or under what condition, does default lazyLoadingEnabled='true' work?

Thanks,



----- Original Message ----- 
From: "xianwinwin" <xi...@gmail.com>
To: <us...@ibatis.apache.org>
Sent: Thursday, June 15, 2006 2:52 PM
Subject: Re: lazy loading


>
> hi there, i just had the same problem and i found it in the tutorial at:
>
> http://people.apache.org/dist/ibatis/ibatis.java/docs/iBATIS-SqlMaps-2.pdf
>
> page 36
> hope this helps
> --
> View this message in context: 
> http://www.nabble.com/lazy-loading-t1789831.html#a4876489
> Sent from the iBATIS - User - Java forum at Nabble.com.
> 


Re: lazy loading

Posted by xianwinwin <xi...@gmail.com>.
hi there, i just had the same problem and i found it in the tutorial at:

http://people.apache.org/dist/ibatis/ibatis.java/docs/iBATIS-SqlMaps-2.pdf

page 36
hope this helps
--
View this message in context: http://www.nabble.com/lazy-loading-t1789831.html#a4876489
Sent from the iBATIS - User - Java forum at Nabble.com.