ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: n+1 is triggering multiple queries, 3?
Date Thu, 14 Jul 2005 12:18:15 GMT
The Java version of iBATIS has support for logging all sql sent to the
database. Here's some sample output:

 http://issues.apache.org/jira/browse/IBATISNET-35

--- Kris Rasmussen <kristapestry@yahoo.com> wrote:

> Thanks Clinton,
>  
> I will look into this myself when I have more time. I wish there were
> a MySql Profiler or something so that I could see what queries are
> actually being executed. Maybe I will step into your code if I get a
> chance.
>  
> Kris
> 
> Clinton Begin <clinton.begin@gmail.com> wrote:
> Kris,
> 
> This is the right list (user-java@ibatis.com).
> 
> Sorry nobody responded.  I had a quick look when you originally sent
> it, and I couldn't see how it was possible that the groupBy or a
> nested resultMap could cause additional queries...
> 
> Perhaps someone else has thoughts?  If not, you might have to write
> an isolated unit test and submit it through JIRA.
> 
> Cheers,
> Clinton
> 
> 
> On 7/9/05, Kris Rasmussen <kristapestry@yahoo.com> wrote:I have an
> n+1 mapping. When I look at mysql health in the administrator it
> apears that 3 queries are being executed instead of one. The first
> query gets executed when I retrieve the intial object via
> queryForObject. The next two queries are being executed when I
> attempt to access the List which stores the related objects from the
> main object. I am very curious what is going on since I don't know
> how Ibatis could even know what query to execute to get the items
> later?
>  
> The following maps are used to retrive a single instance of classB
> with all of its classA children stored in one of its properties which
> is of course a list.
>  
> 
> <resultMap id="getClassAResult" class="classA">
> 
> ... some basic properties
> 
> </resultMap>
> 
> 
> 
> <resultMap id="getClassBResult" class="classB">
> 
> <result property="primKey1" column="classB.primKey1"/>
> 
> <result property="primKey2" column="classB.primKey2"/>
> 
> ... some more properties
> 
> </resultMap>
> 
> 
> 
> <resultMap id="getClassBWithClassAsResult" class="classB"
> extends="getClassBResult" groupBy="primKey1,primKey2">
> 
> <result property="classAs" resultMap="namespace.getClassAResult"/>
> 
> </resultMap>
> 
>  
> 
> and my select statement...
> 
> <select id="getClassBWithClassAs" parameterClass="keyClass"
> resultMap="getClassBWithClassAsResult">
> 
> SELECT classB.*,classA.* FROM classB ,classA
> 
> WHERE classB.primKey1=#primKey1# AND classB.primKey2=#primKey2# AND
> gallery_image.SiteId=#siteId# AND gallery_image.BlockId=#blockId#
> 
> GROUP BY classB.primKey1,classB.primKey2,classA.primKey3
> 
> </select>
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> 
> 
> 		
> ---------------------------------
>  Start your day with Yahoo! - make it your home page 


Mime
View raw message