ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Maves <nathan.ma...@gmail.com>
Subject Re: SubQuery
Date Fri, 17 Apr 2009 03:07:09 GMT
Start at the bottom of page 38 of the developers guide.  You might even want
to read the whole thing because it might show you a better way to achieve
what you are looking for.  Right now you have the makings of a n+1 problem.
Nathan

On Thu, Apr 16, 2009 at 2:35 PM, Aleksandr Elbakyan <ramalex1@yahoo.com>wrote:

> Hello,
>
> I have
>
> class A{
> private Integer id;
> private Set* primB;
> private Set secBs;
> private Set<Integer> allBIds;
> .....
> }
> class B{
> private Integer id;
> private String name;
> ....
> }
>
>   <select id="getIds" parameterClass="map"
>  resultClass="java.lang.Integer">
>     <![CDATA[
>           select distinct B_id from B
>           start with
>           b_id in (#parentId#,#ids#)
>           connect by PRIOR PARENT_B_ID=B_id
>         ]]>
>   </select>
>
>   <select id="getAs" parameterClass="map"
>     resultMap="th.A">
>  ....
>         ]]>
>
> </select>
>
>
>   <resultMap id="A" class="my.A">
>     <result property="id" column="A_ID" />
>     <result property="primB" resultMap="my.PB" />
>     <result property="secBs" resultMap="my.SB" />
>     <result property="allBIds" select="getIds"/>
>   </resultMap>
>
>
> I don't know how to pass into getIds subquery PrimB and secBs can anybody
> help please?
>
> Thanks
> *
>

Mime
View raw message