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 Luke Siler <lu...@lsbio.com> on 2006/08/21 21:36:54 UTC

Composite Key parameter

Hi,

I'm trying to expand a 1:M collection property based on a composite key.
The 1.3 Data Mapper Guide shows a sample of composite key parameter
mapping as follows:


Example 3.44. Mapping a composite key
<resultMaps>
<resultMap id="select-order-result" class="order">
<result property="id" column="ORD_ID"/>
<result property="customerId" column="ORD_CST_ID"/>
...
<result property="payments" column="{itemId=ORD_ID, custId=ORD_CST_ID}"
select="selectOrderPayments"/>
</resultMap>
<resultMaps>
<statements>
<statement id="selectOrderPayments" resultMap="select-payment-result">
select * from PAYMENT
Working with Data Maps
DataMapper Guide Version 1.3.0 40
where PAY_ORD_ID = #itemId#
and PAY_CST_ID = #custId#
</statement>
</statements>
Optionally you can just specify the column names as long as they're in
the same order as the
parameters. For example:
{ORD_ID, ORD_CST_ID}




However, this syntax expressed in the result map below yields the
following error message for me.  Basically, the trailing bracket "}" is
not getting parsed out properly.  If I remove the brackets then I don't
get any error but only one column of the two always seems to win.


Test method
LS.Antibody.Inventory.Persist.Test.AntibodyMakeImplTest.AntibodyMakeDao_
Get_TestMethod threw exception:  System.IndexOutOfRangeException: LSID}.


<result property="Alternatives" column="{AntibodyID, LSID}"
select="ABPOGetAntibodyByLSID"/>



I haven't seen any other activity on the list about this problem so
guessing I must be doing something wrong.  I've tried changing order of
columns, stored procedure parameters, played with aliasing, removing
spaces, etc.  Nothing seems to work.

Is this only supported for inline parameter mapping with <statement>
rather than <procedure>?


Luke Siler
Software Engineer
LifeSpan BioSciences, Inc.
lukes@lsbio.com
206.374.1135 


Re: Composite Key parameter

Posted by Gilles Bayon <ib...@gmail.com>.
It's a documentation issue that have been fixed see JIRA IBATISNET-141.

You can check order.xml mapping for exemples.
It's supported by all 'statement' tag.


-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>