On Tue, Nov 18, 2008 at 3:43 PM, Raymond McDermott <[EMAIL PROTECTED]> 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.