ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raymond McDermott" <...@mcdermott.be>
Subject Re: Am I missing something really simple? Way to avoid adding all props in a map if I decide to add one extra collection to pojo
Date Tue, 18 Nov 2008 23:31:20 GMT
Sorry Rick I misunderstood.  You are right that is clearly limiting.
I expected nested classes to have the same automatic reflection style

Chalk up one more disappointed user.

2008/11/18 Rick <rickcr@gmail.com>

> On Tue, Nov 18, 2008 at 3:43 PM, Raymond McDermott <ray@mcdermott.be>
> wrote:
> > iBatis supports automatically mapping in beans where the property names
> > match the getters/setters so you are in luck ;-)
> I understand that but that ONLY works for when you are mapping one
> statement to a class.
> Look at that example on page 33 you mention. It maps the result set to
> "Product" but if you also wanted to return "List<ProductPart>
> productParts" ?
> How would you do it? You'd have to create a resultMap and apparently
> add EVERY product property to the map just so you can add the
> collection productParts to your result map. And on top of that you
> also will need a map of every property for your ProductPart because
> (as far as I can tell) you can't map a result property to a Class -
> only a map?
> <resultMap id="productMap" class="Product" groupBy="productID">
>       <!-- ALL THE OTHER PROPS? --->
>      <!-- can't do this below bc can' map producParts to a 'resultClass'
> --->
>     <result property="productParts" resultClass="ProductPart"/>
> </resultMap>
> Obviously the above isn't a big deal if just returning one product
> since you could just make two queries, but if you want a list of all
> products and their product parts, you now have a different situation
> and you seem to HAVE to have all properties in a result map.
> It just seems verbose to have to have all those mapped properties
> defined just to allow for some nesting of other objects.

Ray McDermott
GSM 047/32.53.854

View raw message