ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Problem with avoiding N+1 queries on complex collection property
Date Thu, 02 Feb 2006 06:42:24 GMT
#1 After thinking about it, I agree an empty list would be better

#2 Following is our unit test that succeeds. From looking at your
configs I could see that the problem is related to the nesting depth
(contactInfo.phoneNumbers). In our unit test we'll have to add a test
to our test case that mimics this issue and resolve it. Between
yourself and Tony can you guys check to see if an issue exists for
this and then create one if it does not. Currently the only way to
resolve this is your original solution.

Successful unit test configs:

<resultMap id="categoryResult" class="testdomain.Category" groupBy="categoryId">
    <result property="categoryId" column="catid"/>
    <result property="name" column="catname"/>
    <result property="description" column="catdescn"/>
    <result property="productList" resultMap="productResult"/>

  <resultMap id="productResult" class="testdomain.Product" groupBy="productId">
    <result property="productId" column="productid"/>
    <result property="categoryId" column="category"/>
    <result property="name" column="prodname"/>
    <result property="description" column="proddescn"/>
    <result property="itemList" resultMap="itemResult"/>

  <select id="getAllCategories" resultMap="categoryResult" >
       c.catid, c.name as catname, c.descn as catdescn,
       p.productid, p.category, p.name as prodname,
       p.descn as proddescn, i.itemid, i.productid,
       i.listprice, i.unitcost, i.supplier, i.status,
       i.attr1, i.attr2, i.attr3, i.attr4, i.attr5,
       v.itemid, v.qty
    from category c, product p, item i, inventory v
    where c.catid = p.category
      and p.productid = i.productid
      and i.itemid = v.itemid


On 2/1/06, James Hillyerd <james@hillyerd.com> wrote:
> I think an empty List would make more sense than null, but that's
> besides the point.  It's always setting it to null, even when there
> are four phone numbers.  I get no phone numbers period when I try to
> avoid N+1.
> -james
> On 2/1/06, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> > I'm curious here. If you want a List to always be there wouldn't it
> > make sense to instantiate a list and set it in the constructor of your
> > Client object? If you do this does ibatis set it to null when there
> > are no phone numbers? I would prefer that ibatis not make assumptions
> > about what default values that you want set on your object. If ibatis
> > is forcing it to null then i think that should be considered a bug and
> > entered into a bug report. If it does not then I think that it is the
> > developer's job insure defaults to be set.
> >
> > Brandon Goodin
> >
> --
> James A. Hillyerd <james@hillyerd.com>
> Chief Technical Officer - ActiveRain Corp

View raw message