ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farsi, Reza" <Reza.Fa...@SUNGARD.DE>
Subject How many select calls for Loading an object and referenced objects
Date Tue, 06 Sep 2005 09:11:35 GMT

I'm new to iBATIS. 

Following question:
When a class is referencing an another class, how can I load the referencing class with only
one select. Imagine, you have classes Fund and Transaction. Transaction has in database a
filed for fund_id that references a Fund.

At the Moment, I have two mapping files for Fund and Transaction. In the mapping for Fund
I've a select as follows:
	<select id="getFundById" resultMap="fund" parameterClass="int">
		select * from fund where id=#value#

In mapping file for transaction I've the following statements:
	<resultMap id="tansaction" class="transaction">
		<result property="id" column="id"/>
		<result property="fund" select="getFundById" column="fund_id"/>
	<select id="getAllTransactions" resultMap="transaction">
		SELECT * FROM transaction

I assume, that the call of getAllTransactions leads to call of both selects. If I'm right,
is it possible to optimize the select call by mapping the referencing and referenced objects
in only one select call using join?

Thanks and Regards

View raw message