ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hemant.Kamatgi <Hemant.Kama...@target.com>
Subject RE: Basic mapping in iBatis
Date Tue, 31 Jul 2007 14:01:26 GMT
The resultmap shown below can be used for M:1 relationship also.
For eg:
> <resultMap name="OrderItemMap" class="OrderItems">
> 
> 	<result property="id" column="ORDER_ITEM_I" />
	<result property="order" resultMap="order.OrderMap" />
> 	.....
> </resultMap>

This shud work, I guess.

Regards
Hemant




-----Original Message-----
From: HHB [mailto:hubaghdadi@yahoo.ca] 
Sent: Monday, July 30, 2007 5:45 PM
To: user-java@ibatis.apache.org
Subject: RE: Basic mapping in iBatis


Thank you Hemant.
You showed me how to map the relation from Order to OrderItem.
How to map the other way (OrderItem to Order) at the XML level?
Appreciate your kind help all.



Hemant.Kamatgi wrote:
> 
> Try this(query and result map shown just as an example):
> 
> <sqlMap namespace="order">
> 
> <resultMap name="OrderMap" class="Order" groupby="id">
> 
> 	<result property="id" column="ORDER_I">
> 	...
> 	<result property="orderItemList" resultMap="order.OrderItemMap">
> </resultMap>
> 
> <resultMap name="OrderItemMap" class="OrderItems">
> 
> 	<result property="id" column="ORDER_ITEM_I" />
> 	.....
> </resultMap>
> 
> <select name=getOrderDetails" parameterClass="Order"
> resultMap="OrderMap">
> 
> 	Select *
> 	From	Order or,
> 		OrderItem oi
> 	Where	or.id=#id#
> 	And	or.id=oi.id
> </select>
> 
> </sqlMap>
> 
> Rgds
> Hemant
> 
> -----Original Message-----
> From: HHB [mailto:hubaghdadi@yahoo.ca] 
> Sent: Friday, July 27, 2007 6:21 PM
> To: user-java@ibatis.apache.org
> Subject: Basic mapping in iBatis
> 
> 
> Hi.
> I have these two entites: Order and OrderItem
> ------------------
> class Order {
>   List orderItems;
> }
> class OrderItems {
>   Order order;
> }
> -----------------
> How to map this relationship at the XML level?
> How can I load an Order with all its order items are fully initialized
> (no 1
> + N problem please)?
> Thanks for help.
> -- 
> View this message in context:
> http://www.nabble.com/Basic-mapping-in-iBatis-tf4160616.html#a11838111
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> 
> 

-- 
View this message in context:
http://www.nabble.com/Basic-mapping-in-iBatis-tf4160616.html#a11885569
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

Mime
View raw message