ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: subselects design
Date Mon, 03 Jan 2005 15:44:10 GMT
Hi Emiliano,

Couple of things:

1) It looks like product and/or price are 1:1 Or M:1 with your parent
object, so why not just join the data?  I would avoid the second
select, as you're creating an N+1 problem (1 primary select + 100
--one for each record).  Even if it's a collection, version 2.0.9 can
handle joined data for populating complex collections.

2) RowHandler is a fine way to do anything where you only need/want to
process a single row at a time.  If you're trying to create a list of
objects in memory, don't use RowHandler, just use queryForList().

Cheers,

Clinton


On Mon, 03 Jan 2005 15:42:26 +0100, Emiliano Armellin
<earmellin@ateikon.com> wrote:
>  Hello
>  
>  I'm a bit confused about the right pattern to implement this kind of
> selects with ibatis.
>  
>  This is the problem: I've got a select to search products in db. I'm using
> queryForList(java.lang.String id, java.lang.Object parameterObject, int
> skip, int max)  to extract the first 100 records. 
>  For every product extracted by this select I have to do other selects to
> get price/promotions/etc 
>  This subselects take the product.cd as parameters and others parameters not
> in the column of the parent select but passed to the method
> searchProducts(Map pars), so I can't use construct like:
>  
>  <result property="product" column="{id=PROD_CD}" select="getProdPrice"/>
>  
>  because getProdPrice needs PROD_CD but also user.cdlist, user.cdcompany...
> am I wrong?
>  
>  Is rowHandler implementations the correct way to do this?
>  
>  
>  
>  
> -- 
>  
> Emiliano Armellin 
>  
> W_ www.ateikon.com 
>  
> @_ earmellin@ateikon.com 
>  
> T_ 
> +39 0422 452101 
>  
>

Mime
View raw message