I had similar problems... could not get a list of strings working. In the
end I made a class with one property.
I think it's a bug.

On 8/21/07, Nicholas Piasecki <[EMAIL PROTECTED]> wrote:
>
> I might be having a moment, but here goes.
>
> I have a Coupon class that contains an integer list of BrandIds that
> specifies which brands of product the coupon is good for. We don't want
> the whole Brand object because it contains a lot of information that's
> not necessary for the coupon's CalculateDiscount() method to function,
> so we'd just like a list of integers returned from iBATIS. int[],
> List<int>, just a list of integers of some sort.
>
> The relevant parts of the database tables look like this:
>
> Coupons:
>    CouponId (PK)
>    Code
>
> Coupons_Brands: (M:N relationship table)
>    CouponId (FK)
>    BrandId (FK)
>
> To avoid the N+1 selects, we tried a SQL statement like the following:
>
> SELECT
> cou.CouponId AS CouponId,
> cou.Code AS CouponCode,
> cou_b.BrandId AS CouponBrandId,
> FROM SkiviezInv.Coupons AS cou
> LEFT OUTER JOIN Coupons_Brands AS cou_b
> ON cou.CouponId = cou_b.CouponId
>
> But then we got stuck at defining the <resultMap>. Just using the
> property and column attributes doesn't work ("no type handler for List`1
> is registered"). The furthest we got was defining another result map for
> the integer type, like this:
>
> <resultMap id="ResultMapCoupon" class="Coupon" groupBy="Id">
>     <result column="CouponId" property="Id" />
>     <result
>       property="BrandIds"
>       resultMapping="Coupon.ResultMapCouponBrandId" />
> </resultMap>
>
> <resultMap id="ResultMapCouponBrandId" class="int">
>     <result property="value" column="CouponBrandId" />
> </resultMap>
>
> This set up would indeed create a List<int> with the proper Count (e.g.,
> two BrandIds), but they're always all set to 0. It seems like this would
> be supported (see example 3.41 in the DataMapper documentation), but it
> just doesn't seem to work.
>
> We've worked around it by just using the select attribute and getting
> rid of the join.
>
> This is on DataMapper 1.6.1.
>
> Thanks for any insight!
>
> V/R,
> Nicholas Piasecki
>

Reply via email to