You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "MCCORMICK, Paul" <Pa...@doir.wa.gov.au> on 2007/07/04 05:21:57 UTC

Inner select statements in resultMaps

Dear List,
I'm using lazy loading for inner select statements in results maps.  Is
it possible to hard code a parameter that's passed to the inner select
statement.  See below.  I would like the string "BIG_SPENDER" to be
passed to the query getOrderPayments.  Is this possible? 

<resultMap id="get-order-result" class="com.ibatis.example.Order">
	<result property="id" column="ORD_ID"/>
	<result property="customerId" column="ORD_CST_ID"/>
	<result property="payments" column="{itemId=ORD_ID,
custType='BIG_SPENDER'}" select="getOrderPayments"/>
</resultMap>

<select id="getOrderPayments" resultMap="get-payment-result">
	select ORD_ID, ORD_CST_ID
	from PAYMENT
	where PAY_ORD_ID = #itemId#
	and PAY_CST_TYPE = #custType#
</select>


Thanks,
Paul


"DISCLAIMER: This email, including any attachments, is intended only for use by the addressee(s) and may contain confidential and/or personal information and may also be the subject of legal privilege. If you are not the intended recipient, you must not disclose or use the information contained in it. In this case, please let me know by return email, delete the message permanently from your system and destroy any copies.

Before you take any action based upon advice and/or information contained in this email you should carefully consider the advice and information and consider obtaining relevant independent advice.

Re: Inner select statements in resultMaps

Posted by Lisa Jenkins <li...@investoranalytics.com>.
Hi paul,

Why not just hard code it in the query ?

      *select ORD_ID, ORD_CST_ID*
      *from PAYMENT*
      *where/ PAY_ORD_ID/ = #itemId#*
      *and/ PAY_CST_TYPE/ = **/'BIG_SPENDER'/*




MCCORMICK, Paul wrote:
>
> Dear List,
> I'm using lazy loading for inner select statements in results maps. Is 
> it possible to hard code a parameter that’s passed to the inner select 
> statement. See below. I would like the string "BIG_SPENDER" to be 
> passed to the query* getOrderPayments*. Is this possible?
>
> *<resultMap id=”get-order-result” class=”com.ibatis.example.Order”>*
>
>       *<result property=”id” column=”ORD_ID”/>*
>       *<result property=”customerId” column=”ORD_CST_ID”/>*
>       *<result property=”payments” column=”/{itemId=ORD_ID,/
>       custType/='BIG_SPENDER'}/” select=”getOrderPayments”/>*
>
> *</resultMap>*
>
> *<select id=”getOrderPayments” resultMap=”get-payment-result”>*
>
>       *select ORD_ID, ORD_CST_ID*
>       *from PAYMENT*
>       *where/ PAY_ORD_ID/ = #itemId#*
>       *and/ PAY_CST_TYPE/ = #custType#*
>
> *</select>*
>
>
> Thanks,
> Paul
>
> "DISCLAIMER: This email, including any attachments, is intended only 
> for use by the addressee(s) and may contain confidential and/or 
> personal information and may also be the subject of legal privilege. 
> If you are not the intended recipient, you must not disclose or use 
> the information contained in it. In this case, please let me know by 
> return email, delete the message permanently from your system and 
> destroy any copies.
>
> Before you take any action based upon advice and/or information 
> contained in this email you should carefully consider the advice and 
> information and consider obtaining relevant independent advice.
>