Java Reference
In-Depth Information
class="org.apache.mapper2.examples.bean.OrderInfo">
<result property="order.orderId" column="orderId" />
<result property="orderItemList" column="orderId"
select="Ch6.getOrderItemList" />
</resultMap>
D
<resultMap id="ResultOrderItemMap"
class="org.apache.mapper2.examples.bean.OrderItem">
<result property="orderId" column="orderId" />
<result property="orderItemId" column="orderItemId" />
</resultMap>
E
<select id="getAccountInfoList"
resultMap="ResultAccountInfoMap" >
select accountId
from Account
</select>
F
<select id="getOrderInfoList"
resultMap="ResultOrderInfoMap">
select orderId
from orders
where accountId = #value#
</select>
G
<select id="getOrderItemList"
resultMap="ResultOrderItemMap">
select
orderId,
orderItemId
from orderItem
where orderid = #value#
</select>
</sqlMap>
b
C
If you look at the result maps ( ResultAccountInfoMap , ResultOrderInfoMap ,
and ResultOrderItemMap ), you will see that the first two use the select
attribute for one of the mapped properties. The presence of that attribute tells
i BATIS that the property is to be set using the results of another mapped state-
ment, which is named by its value. For example, when we run the getAccountIn-
foList mapped statement , the ResultAccountInfoMap result map has <result
property="orderList" select="Ch6.getOrderInfoList" column="accountId" /> .
That tells i BATIS to get the value for the orderList property by running the
"Ch6.getOrderInfoList" mapped statement , passing it the value of the
accountId column, and then putting the returned data into orderList . Similarly,
D
E
F
Search WWH ::




Custom Search