ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject RE: lazy loading confusion
Date Wed, 27 Sep 2006 15:29:09 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii" 
urn:content-classes:message Content-class: plain; text Content-Type: 
quoted-printable Content-Transfer-Encoding:>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=374032615-27092006><FONT color=#0000ff

size=2>I'm using the latest from iBatis, which I compiled myself from svn last 
week. I'm using Spring 2.0 rc4 and I have both enhancementEnabled and 
lazyLoadingEnabled set to true, and I am experiencing no problems. Lazy loading 
is working as expected. Here's the snippet from my 
sql-map-config.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=374032615-27092006><FONT color=#0000ff

size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=374032615-27092006><FONT color=#0000ff

size=2>&nbsp; &lt;settings<BR>&nbsp;&nbsp;&nbsp; 
cacheModelsEnabled="true"<BR>&nbsp;&nbsp;&nbsp; 
errorTracingEnabled="true"<BR>&nbsp;&nbsp;&nbsp; 
enhancementEnabled="true"<BR>&nbsp;&nbsp;&nbsp; 
lazyLoadingEnabled="true"<BR>&nbsp;&nbsp;&nbsp; 
maxSessions="250"<BR>&nbsp;&nbsp;&nbsp; 
maxTransactions="30"<BR>&nbsp;&nbsp;&nbsp; 
maxRequests="500"<BR>&nbsp;&nbsp;&nbsp; 
useStatementNamespaces="true"/&gt;</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> "Poitras Christian" 
&lt;Christian.Poitras@ircm.qc.ca&gt; [mailto:"Poitras Christian" 
&lt;Christian.Poitras@ircm.qc.ca&gt;] <BR><B>Sent:</B> Wednesday,
September 27, 
2006 7:55 AM<BR><B>To:</B> 
&lt;user-java@ibatis.apache.org&gt;<BR><B>Subject:</B> RE: lazy
loading 
confusion<BR></FONT><BR></DIV>
<DIV></DIV>Hum... The requirements indicates that CGLIB 2.0 should be used. But

I <BR>doubt this would change anything. <BR>I'm not using Spring, but if this

sort of problem is normal with Spring, <BR>the mailing list would already 
contain a solution. <BR><BR>Can anyone confirm that lazy loading works with 
Spring? <BR><BR>If so, then maybe it is the Spring configuration that is 
problematic. <BR><BR>Christian <BR><BR>-----Original Message-----
<BR>From: Tom 
Duffey [mailto:tduffey@utilivisor.com] <BR>Sent: Wednesday, 27 September 2006 
10:44 <BR>To: user-java@ibatis.apache.org <BR>Subject: Re: lazy loading 
confusion <BR><BR><BR>On Sep 27, 2006, at 9:40 AM, Poitras Christian wrote:

<BR><BR>&gt; Try to turn on enhancement (also add needed jar) for lazy loading

and <BR>&gt; see what happens. <BR><BR>Same thing. I'm using CGLIB 2.1
which was 
the oldest version I could <BR>find on their site. <BR><BR>Tom <BR><BR>&gt;

-----Original Message----- <BR>&gt; From: Tom Duffey 
[mailto:tduffey@utilivisor.com] <BR>&gt; Sent: Wednesday, 27 September 2006 
10:34 <BR>&gt; To: user-java@ibatis.apache.org <BR>&gt; Subject: Re: lazy

loading confusion <BR>&gt; <BR>&gt; <BR>&gt; On Sep 27, 2006,
at 9:28 AM, 
Poitras Christian wrote: <BR>&gt; <BR>&gt;&gt; Maybe your application
is 
accessing the "members" property when the <BR>&gt;&gt; object is populating.

<BR>&gt;&gt; <BR>&gt;&gt; Try to turn on logging and see what
happens. Add a log 
statement in <BR>&gt;&gt; your "members" property getter to be sure. <BR>&gt;

<BR>&gt; Did this. The getter is never called, only the setter. This <BR>&gt;

application is using Spring 1.x for some AOP logging, could it be <BR>&gt; 
manipulating some bytecode somehow to make iBATIS think it needs to <BR>&gt; 
load the data? <BR>&gt; <BR>&gt; Tom <BR>&gt; <BR>&gt;&gt;
<BR>&gt;&gt; 
Christian <BR>&gt;&gt; <BR>&gt;&gt; -----Original Message-----
<BR>&gt;&gt; 
From: Tom Duffey [mailto:tduffey@utilivisor.com] <BR>&gt;&gt; Sent: Wednesday,

27 September 2006 09:25 <BR>&gt;&gt; To: user-java@ibatis.apache.org 
<BR>&gt;&gt; Subject: Re: lazy loading confusion <BR>&gt;&gt;
<BR>&gt;&gt; 
<BR>&gt;&gt; On Sep 27, 2006, at 1:41 AM, Niels Beekman wrote: <BR>&gt;&gt;

<BR>&gt;&gt;&gt; Can we see your config? <BR>&gt;&gt; <BR>&gt;&gt;
What all 
would you like to see? It's a large application and the <BR>&gt;&gt; example
I 
posted is just a snippet. Here's more from my sql config <BR>&gt;&gt; and dao

config: <BR>&gt;&gt; <BR>&gt;&gt; <SQLMAPCONFIG><BR>&gt;&gt;
<PROPERTIES 
resource="org/projectFoundry/config/&#13;&#10;<BR>>> jdbc.properties"

/><BR>&gt;&gt; <BR>&gt;&gt; <SETTINGS enhancementEnabled="true"
/><BR>&gt;&gt; 
<BR>&gt;&gt; <TRANSACTIONMANAGER type="JDBC"><BR>&gt;&gt;
<DATASOURCE 
type="SIMPLE"><BR>&gt;&gt; <property value="${JDBC.Driver}" 
name="JDBC.Driver"></property><BR>&gt;&gt; <property 
value="$ &#13;&#10;<BR>>> {JDBC.ConnectionURL}" 
name="JDBC.ConnectionURL"></property><BR>&gt;&gt; <property 
value="$ &#13;&#10;<BR>>> {JDBC.Username}" 
name="JDBC.Username"></property><BR>&gt;&gt; <property 
value="$ &#13;&#10;<BR>>> {JDBC.Password}" 
name="JDBC.Password"></property><BR>&gt;&gt; </DATASOURCE><BR>&gt;&gt;

</TRANSACTIONMANAGER><BR>&gt;&gt; <BR>&gt;&gt; <SQLMAP

resource="org/projectFoundry/persistence/project/&#13;&#10;<BR>>> ProjectSqlMap.xml"

/><BR>&gt;&gt; <SQLMAP 
resource="org/projectFoundry/persistence/user/&#13;&#10;<BR>>> UserSqlMap.xml"

/><BR>&gt;&gt; etc. <BR>&gt;&gt; </SQLMAPCONFIG><BR>&gt;&gt;
<BR>&gt;&gt; 
<DAOCONFIG><BR>&gt;&gt; <CONTEXT><BR>&gt;&gt; <BR>&gt;&gt;
<TRANSACTIONMANAGER 
type="SQLMAP"><BR>&gt;&gt; <property 
value="org/ &#13;&#10;<BR>>> projectFoundry/config/sql-map.xml" 
name="SqlMapConfigResource"></property><BR>&gt;&gt; 
</TRANSACTIONMANAGER><BR>&gt;&gt; <BR>&gt;&gt; <DAO <BR>&gt;&gt;

interface="org.projectFoundry.persistence.project.ProjectDao" <BR>&gt;&gt; 
implementation="org.projectFoundry.persistence.project.ProjectSqlMapD 
<BR>&gt;&gt; a <BR>&gt;&gt; o" <BR>&gt;&gt; <BR>&gt;&gt;
/&gt; <BR>&gt;&gt; <DAO 
<BR interface="org.projectFoundry.persistence.user.UserDao">&gt;&gt; 
implementation="org.projectFoundry.persistence.user.UserSqlMapDao"/&gt; 
<BR>&gt;&gt; etc. <BR>&gt;&gt; </CONTEXT><BR>&gt;&gt;
</DAOCONFIG><BR>&gt;&gt; 
<BR>&gt;&gt; Tom <BR>&gt;&gt; <BR>&gt;&gt;&gt;
<BR>&gt;&gt;&gt; -----Original 
Message----- <BR>&gt;&gt;&gt; From: Tom Duffey [mailto:tduffey@utilivisor.com]

<BR>&gt;&gt;&gt; Sent: woensdag 27 september 2006 7:34 <BR>&gt;&gt;&gt;
To: 
user-java@ibatis.apache.org <BR>&gt;&gt;&gt; Subject: lazy loading confusion

<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt; Hi All, <BR>&gt;&gt;&gt;
<BR>&gt;&gt;&gt; I 
have a Project class with a list of Members. It is my <BR>&gt;&gt;&gt; 
understanding <BR>&gt;&gt; <BR>&gt;&gt;&gt; that I can turn
on lazy loading in 
my sql map config, define a <BR>&gt;&gt;&gt; Project <BR>&gt;&gt;

<BR>&gt;&gt;&gt; result map like: <BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;
<RESULTMAP 
class=foo.Project id=result><BR>&gt;&gt;&gt; <RESULT column="id" 
property="projectId" /><BR>&gt;&gt;&gt; <RESULT <BR column="id"

property="members">&gt;&gt;&gt; select="Member.listByProject"/&gt; 
<BR>&gt;&gt;&gt; </RESULTMAP><BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;
and then retrieve 
a project and the members will not be retrieved <BR>&gt;&gt;&gt; unless
I call 
getMembers() on the project instance. Is this how <BR>&gt;&gt;&gt; it's
<BR>&gt; 
<BR>&gt;&gt;&gt; supposed to work? What I'm finding is that the members
list is 
<BR>&gt;&gt;&gt; populated even if I do not call getMembers(). To back this
idea 
I <BR>&gt;&gt;&gt; renamed the property in the result map to "members2"
and 
added a new <BR>&gt;&gt;&gt; members2 attribute to the project class (To
make 
sure I didn't miss <BR>&gt;&gt;&gt; any calls to getMembers) and sure enough
it 
is still populated when <BR>&gt;&gt;&gt; I <BR>&gt; <BR>&gt;&gt;&gt;
retrieve 
the project. <BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt; What gives?
I thought the point 
of lazy loading was to not load <BR>&gt;&gt;&gt; data <BR>&gt;
<BR>&gt;&gt;&gt; 
unless I ask for it. I'm using iBATIS 2.1.7 for Java. <BR>&gt;&gt;&gt; 
<BR>&gt;&gt;&gt; Best Regards, <BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;
Tom Duffey 
<BR>&gt;&gt; <BR>&gt;&gt; <BR>&gt; <BR>&gt;
<BR><BR><BR><BR></BODY></HTML>


Mime
View raw message