ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sachin.x.maha...@jpmchase.com
Subject Re: One Bean, multiple queries
Date Fri, 13 Jul 2007 08:18:38 GMT
Hi Vinay,

Checkout this result map in which category is a member of Product. This 
way you can bind queries to produce single result.
I hope this is what you have asked for.
This sample if from the IBatis tutorial.

<resultMap id=”get-product-result” class=”com.ibatis.example.Product”>
<result property=”id” column=”PRD_ID”/>
<result property=”description” column=”PRD_DESCRIPTION”/>
<result property=”category” column=”PRD_CAT_ID” select=”getCategory”/>
<resultMap id=”get-category-result” class=”com.ibatis.example.Category”>
<result property=”id” column=”CAT_ID”/>
<result property=”description” column=”CAT_DESCRIPTION”/>
<statement id=”getProduct” parameterClass=”int” 
select * from PRODUCT where PRD_ID = #value#
<statement id=”getCategory” parameterClass=”int” 
select * from CATEGORY where CAT_ID = #value#


vinays84 <vinays84@hotmail.com> 
07/13/2007 06:00 AM
Please respond to


One Bean, multiple queries

I'm curious if iBatis can somehow handle mapping results to an existing
object or whether it must always create a new result object. Consider a
situation where a few queries are need to define a bean (for example a
specific report where the main data will have multiple rows and called 
query A, and the summary information will be one row and called from query
B). If a JavaBean class is created capable of storing data from all the
queries, the DAO would need to call each query, creating multiple 
of the bean, each with data the other one desires. The developer would 
be tasked with manually merging all the data in to one main bean, which
could be tedious if each query contains a lot of data. Can iBatis handle
grabbing a partially populated bean and fully populating it from another
query? If not, how would one best tackle the example situation I 
View this message in context: 

Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

This communication is for informational purposes only. It is not
intended as an offer or solicitation for the purchase or sale of
any financial instrument or as an official confirmation of any
transaction. All market prices, data and other information are not
warranted as to completeness or accuracy and are subject to change
without notice. Any comments or statements made herein do not
necessarily reflect those of JPMorgan Chase & Co., its subsidiaries
and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.

Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
View raw message