ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prateek Asthana" <hkprat...@gmail.com>
Subject Complex Collections - More than one foreign key
Date Sun, 25 May 2008 00:51:35 GMT
Below snippet helps us retrieve data from two tables linked by a
single foreign key.

<resultMap id="ResultOrderInfoMap"
	<result property="order.orderId" column="orderId" />
	<result property="orderItemList" column="orderId"
select="Ch6.getOrderItemList" />

<resultMap id="ResultOrderItemMap"
	<result property="orderId" column="orderId" />
	<result property="orderItemId" column="orderItemId" />

<select id="getOrderInfoList" resultMap="ResultOrderInfoMap">
	select orderId from orders where accountId = #value#

<select id="getOrderItemList" resultMap="ResultOrderItemMap">
	select orderId, orderItemId from orderItem
	where orderid = #value#

In above case, records from both table are retrieved using
orderItem.orderId=orders.orderId; This case has only has one foreign
key constrant;

If the scenario involved two columns as foreign key constraints i.e
orderItem.orderId=orders.orderId AND orderItem.origin=orders.origin
then how could we specify that ?


View raw message