ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Babitha <Babitha.Srid...@ge.com>
Subject Re: Populate List within object in iBatis
Date Tue, 02 Jun 2009 06:57:17 GMT

Thanks Alin. The solution worked. :)

But I was just wondering if applying a join on the 2 tables would be okay.
If i have to fetch quite a number of fields, then wouldn't the join be a
performance issue?

Regards,
Babitha


Alin Popa wrote:
> 
> Hi Babitha,
> 
> Hopefully that I understand right your issue, so, here is how I made it
> (and
> I think also this is the iBatis way to handle it)
> 
> <sqlMap namespace="MyObject">
> 
>     <resultMap id="result" class="org.test.MyObject" groupBy="id">
>         <result property="id" column="id" columnIndex="1" />
>         <result property="name" column="name" columnIndex="2" />
>         <result property="details" column="details" columnIndex="3" />
>         <result property="properties" resultMap="MyObject.resultProperty"
> />
>     </resultMap>
> 
>     <resultMap class="org.test.Property" id="resultProperty">
>         <result property="objId" column="obj_id" />
>         <result property="name" column="property_name" />
>         <result property="value" column="property_value" />
>     </resultMap>
> 
>     <select id="getMyObjects" resultMap="result"
> parameterClass="java.util.Map">
>         SELECT obj.id as id, obj.name, obj.details, p.id as property_id,
> p.obj_id as obj_id, p.name as property_name, p.value as property_value
>         FROM objects obj LEFT JOIN properties p
>         ON obj.id = p.obj_id WHERE obj.id=#id#
>     </select>
> 
> </sqlMap>
> 
> 
> 
> On Mon, Jun 1, 2009 at 3:39 PM, Babitha <Babitha.Sridhar@ge.com> wrote:
> 
>>
>> Hi,
>>
>> I have a Dealer bean. The Dealer bean contains a List of DealerContact
>> bean
>> objects. I would have to execute 2 select queries to populate Dealer bean
>> and DealerContact bean. I wish to execute both the select queries in one
>> go,
>> such that all the details of Dealer bean including DealerContact property
>> gets populated. But my DealerContact list returns null.
>>
>> I have attached the Dealer bean, DealerContact bean and the xml file
>> containing the queries. Please help me in finding out where I am going
>> wrong.
>>
>> I am making the iBatis call using the below code:
>>
>> List dealerDetailsList =
>> getSqlMapClientTemplate().queryForList("selectDealerDetails", dealer);
>>
>> Thanks in advance for the help extended.
>>
>> - Babitha http://www.nabble.com/file/p23814348/sqlDatabaseQueries.xml
>> sqlDatabaseQueries.xml  http://www.nabble.com/file/p23814348/Dealer.java
>> Dealer.java  http://www.nabble.com/file/p23814348/DealerContact.java
>> DealerContact.java
>> --
>> View this message in context:
>> http://www.nabble.com/Populate-List-within-object-in-iBatis-tp23814348p23814348.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 
> -- 
> Regards,
> 
> Alin
> 
> 

-- 
View this message in context: http://www.nabble.com/Populate-List-within-object-in-iBatis-tp23814348p23827424.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message