ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Grinshpun <va...@ll.mit.edu>
Subject Re: One Bean, multiple queries
Date Thu, 26 Jul 2007 19:54:17 GMT
the result maps may be what you need; but if you truly need to populate 
an object that has already been constructed,
I believe there's an overloaded version of queryForObject that takes an 
additional parameter of an object instance to be modified. **

sachin.x.mahajan@jpmchase.com wrote:
>
> 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>
> <resultMap id=”get-category-result” class=”com.ibatis.example.Category”>
> <result property=”id” column=”CAT_ID”/>
> <result property=”description” column=”CAT_DESCRIPTION”/>
> </resultMap>
> <statement id=”getProduct” parameterClass=”int” 
> resultMap=”get-product-result”>
> select * from PRODUCT where PRD_ID = #value#
> </statement>
> <statement id=”getCategory” parameterClass=”int” 
> resultMap=”get-category-result”>
> select * from CATEGORY where CAT_ID = #value#
> </statement>
>
> Regards,
> Sachin
>
>
>
> *vinays84 <vinays84@hotmail.com>*
>
> 07/13/2007 06:00 AM
> Please respond to
> user-java@ibatis.apache.org
>
>
> 	
> To
> 	user-java@ibatis.apache.org
> cc
> 	
> Subject
> 	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 
> from
> 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 
> instances
> of the bean, each with data the other one desires. The developer would 
> then
> 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 
> described?
> Thanks!
> -- 
> View this message in context: 
> http://www.nabble.com/One-Bean%2C-multiple-queries-tf4071676.html#a11571412
> 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.
>


Mime
View raw message