ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: 1 to N in queryForObject()
Date Mon, 31 Jul 2006 14:25:00 GMT
...and the WIKI:

http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+get+around+the+N+Plus+1+selects+problem

If you follow the instructions on the WIKI and find any issues, please
feel free to add another example, or make corrections.

Larry


On 7/31/06, Jeff Butler <jeffgbutler@gmail.com> wrote:
>
> iBATIS has good support for this.  You'll need to use a List instead of an
> array, and the "groupBy" keyword on your result map.  Look in the
> developer's guide for more information.
>
>
> Jeff Butler
>
>
>
> On 7/31/06, Jane Phillips <jane22124@yahoo.com > wrote:
> >
> >
> > Hi, I am new to iBatis. I have a question for one of my query. I have
> tables:
> >
> > 1.  Product
> >     -- product_id
> >     -- product_description
> >     -- product_name
> >
> > 2. Items
> >     -- item_id
> >     -- product_id
> >     -- item_description
> >     -- item_name
> >
> > The relationship is one product can have many items. query I would like to
> do is :
> > <sqlMap>
> > <select id="getProductItems" resultClass="com.abc.products">
> >
> > SELECT product_id, product_description,product_name,
> item_name from product a, items b WHERE a.product_id = b.product_id and
> a.product_id = #id#
> > </select>
> > </sqlMap>
> >
> > in java, com.abc.products:
> >
> > String product_name;
> > String product_description;
> > String product_id;
> > String[] item_name;
> > and all the getXXX and setXXX methods.
> >
> > The goal is run this query using queryForObject() to get one product and
> all its items to a products object instead of queryForList() to get
> collection of product object with duplicate product_name,
> product_description and product_id. Is it feasible? And how to config the
> sqlMap or other things to do it ?
> >
> > Please advise
> >
> >
> >
> >
> > ________________________________
>  See the all-new, redesigned Yahoo.com. Check it out.
> >
> >
> >
> >
> >
> >
>
>

Mime
View raw message