You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Kenneth Olsen <ke...@gatetrade.net> on 2007/02/27 12:54:44 UTC

Passing System.Collections.IDictionary to sub selects

Hi
 
  <resultMaps>
    <resultMap id="resCatalog" class="Catalog">
      <result property="xID" column="ID" />
      <result property="xName" column="Name"/>
      <result property="xCatalogLines" column="ID" select="GetLines"
lazyLoad="true" />
    </resultMap>
 
    <select id="GetAll" resultMap="resCatalog"
ParameterClass="System.Collections.IDictionary">
      SELECT *
      FROM
      Catalog
      WHERE
      UserID = #UserID#
    </select>
---
    <select id="GetLines " resultMap="resCatalogLine">
      select * FROM CatalogLines WHERE ???
 
 
 
Can the ParameterClass of 'GetAll' (System.Collections.IDictionary)
select statement, be passed to the GetLines statement? I need a value
from the System.Collections.IDictionary in the GetLines statement, where
I placed the three ?.
--
Kenneth Olsen
 

Re: Passing System.Collections.IDictionary to sub selects

Posted by Bob Hanson <mn...@gmail.com>.
If I'm inferring correctly from the info you've provided, I believe
you want to be able to select CatalogLines based on UserId and
CatagoryId?

You can assign composite keys in the Column attribute (see section
3.5.14 of the documentation) using comma separated values of
"param=column".

So instead of:
<result property="xCatalogLines" column="ID" select="GetLines"
lazyLoad="true" />

You can use:
<result property="xCatalogLines" column="catalogID=ID, userID=UserID"
select="GetLines" lazyLoad="true" />

select * FROM CatalogLines WHERE CatalogID = #catalogId# AND UserID = #userId#



On 2/27/07, Kenneth Olsen <ke...@gatetrade.net> wrote:
>
>
>
>
> Hi
>
>
>
>   <resultMaps>
>
>     <resultMap id="resCatalog" class="Catalog">
>
>       <result property="xID" column="ID" />
>
>       <result property="xName" column="Name"/>
>
>       <result property="xCatalogLines" column="ID" select="GetLines"
> lazyLoad="true" />
>
>     </resultMap>
>
>
>
>     <select id="GetAll" resultMap="resCatalog"
> ParameterClass="System.Collections.IDictionary">
>
>       SELECT *
>
>       FROM
>
>       Catalog
>
>       WHERE
>
>       UserID = #UserID#
>
>     </select>
>
> ---
>
>     <select id="GetLines " resultMap="resCatalogLine">
>
>       select * FROM CatalogLines WHERE ???
>
>
>
>
>
>
>
> Can the ParameterClass of 'GetAll' (System.Collections.IDictionary) select
> statement, be passed to the GetLines statement? I need a value from the
> System.Collections.IDictionary in the GetLines statement, where I placed the
> three ?.
>
> --
>
> Kenneth Olsen
>
>